t/dedupe: print dedupe ratio instead of made-up factor
[fio.git] / t / dedupe.c
index 5998138b507435e580b5305eaa5e41025d6a727f..12ede8f0494566017674c97f1295b8c0e6efd372 100644 (file)
@@ -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;
@@ -575,10 +576,12 @@ int main(int argc, char *argv[])
 
        ret = dedupe_check(argv[optind], &nextents, &nchunks);
 
-       if (!bloom)
-               iter_rb_tree(&nextents, &nchunks);
+       if (!ret) {
+               if (!bloom)
+                       iter_rb_tree(&nextents, &nchunks);
 
-       show_stat(nextents, nchunks);
+               show_stat(nextents, nchunks);
+       }
 
        fio_mutex_remove(rb_lock);
        if (bloom)