summaryrefslogtreecommitdiff
path: root/bench.c
diff options
context:
space:
mode:
Diffstat (limited to 'bench.c')
-rw-r--r--bench.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/bench.c b/bench.c
index 75bf32e..a5da95f 100644
--- a/bench.c
+++ b/bench.c
@@ -5,6 +5,8 @@
#include "testcases.h"
#include "sorters.h"
+#include "common.h"
+#include "counts.h"
#define CMP_WIDTH 12
#define MS_WIDTH 6
@@ -33,14 +35,15 @@ int main()
for (size_t size = MIN_SIZE; size <= MAX_SIZE; size *= 10) {
printf("%-*s ", SORT_WIDTH, size == MIN_SIZE ? s->name : "");
for (const struct testcase *t = testcases; t->name; t++) {
- comparisons = 0;
+ clear_all_counts();
t->init(size);
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start)) abort();
s->func(buffer, size, sizeof(int), t->cmp);
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &stop)) abort();
- printf("%*lu %*lu ", CMP_WIDTH, comparisons, MS_WIDTH, timediff_ms(&start, &stop));
+ printf("%*lu %*lu ", CMP_WIDTH, counts[CURRENT].compare, MS_WIDTH, timediff_ms(&start, &stop));
+ print_counts();
assert_sorted(size, t->cmp);
}
printf(" %*zu\n", SIZE_WIDTH, size);