test/ring: use division for cycle count calculation
authorHonnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Sat, 18 Jan 2020 19:32:42 +0000 (13:32 -0600)
committerDavid Marchand <david.marchand@redhat.com>
Sun, 19 Jan 2020 18:23:20 +0000 (19:23 +0100)
Use division instead of modulo operation to calculate more
accurate cycle count.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
app/test/test_ring_perf.c

index 70ee46f..6c2aca4 100644 (file)
@@ -357,10 +357,10 @@ test_single_enqueue_dequeue(struct rte_ring *r)
        }
        const uint64_t mc_end = rte_rdtsc();
 
-       printf("SP/SC single enq/dequeue: %"PRIu64"\n",
-                       (sc_end-sc_start) >> iter_shift);
-       printf("MP/MC single enq/dequeue: %"PRIu64"\n",
-                       (mc_end-mc_start) >> iter_shift);
+       printf("SP/SC single enq/dequeue: %.2F\n",
+                       ((double)(sc_end-sc_start)) / iterations);
+       printf("MP/MC single enq/dequeue: %.2F\n",
+                       ((double)(mc_end-mc_start)) / iterations);
 }
 
 /*
@@ -395,13 +395,15 @@ test_burst_enqueue_dequeue(struct rte_ring *r)
                }
                const uint64_t mc_end = rte_rdtsc();
 
-               uint64_t mc_avg = ((mc_end-mc_start) >> iter_shift) / bulk_sizes[sz];
-               uint64_t sc_avg = ((sc_end-sc_start) >> iter_shift) / bulk_sizes[sz];
+               double mc_avg = ((double)(mc_end-mc_start) / iterations) /
+                                       bulk_sizes[sz];
+               double sc_avg = ((double)(sc_end-sc_start) / iterations) /
+                                       bulk_sizes[sz];
 
-               printf("SP/SC burst enq/dequeue (size: %u): %"PRIu64"\n", bulk_sizes[sz],
-                               sc_avg);
-               printf("MP/MC burst enq/dequeue (size: %u): %"PRIu64"\n", bulk_sizes[sz],
-                               mc_avg);
+               printf("SP/SC burst enq/dequeue (size: %u): %.2F\n",
+                               bulk_sizes[sz], sc_avg);
+               printf("MP/MC burst enq/dequeue (size: %u): %.2F\n",
+                               bulk_sizes[sz], mc_avg);
        }
 }