t/dedupe: fix off-by 1.024 in bandwidth
[fio.git] / t / dedupe.c
index fc280772cb9bf139a9c70a6b521e667e2dafae9d..b3ab0f9b3e60589781b7088ec28871ea1987b782 100644 (file)
@@ -342,7 +342,7 @@ static void show_progress(struct worker_thread *threads, unsigned long total)
                unsigned long nitems = 0;
                uint64_t tdiff;
                float perc;
-               int some_done;
+               int some_done = 0;
                int i;
 
                for (i = 0; i < num_threads; i++) {
@@ -361,7 +361,7 @@ static void show_progress(struct worker_thread *threads, unsigned long total)
                this_items *= blocksize;
                tdiff = mtime_since_now(&last_tv);
                if (tdiff) {
-                       this_items /= tdiff;
+                       this_items = (this_items * 1000) / (tdiff * 1024);
                        printf("%3.2f%% done (%luKB/sec)\r", perc, this_items);
                        last_nitems = nitems;
                        fio_gettime(&last_tv, NULL);
@@ -452,7 +452,7 @@ static int dedupe_check(const char *filename, uint64_t *nextents,
        if (use_bloom) {
                uint64_t bloom_entries;
 
-               bloom_entries = (3 * dev_size ) / (blocksize * 2);
+               bloom_entries = 8 * (dev_size / blocksize);
                bloom = bloom_new(bloom_entries);
        }
 
@@ -475,10 +475,11 @@ static void show_chunk(struct chunk *c)
 
 static void show_stat(uint64_t nextents, uint64_t nchunks)
 {
-       double perc;
+       double perc, ratio;
 
        printf("Extents=%lu, Unique extents=%lu\n", (unsigned long) nextents, (unsigned long) nchunks);
-       printf("De-dupe factor: %3.2f\n", (double) nextents / (double) nchunks);
+       ratio = (double) nextents / (double) nchunks;
+       printf("De-dupe ratio: 1:%3.2f\n", ratio - 1.0);
 
        perc = 1.00 - ((double) nchunks / (double) nextents);
        perc *= 100.0;