From 7e76ff5acd182ca1a83242e094f2465d4b9a6040 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Sun, 3 Aug 2014 13:24:36 -0500 Subject: Make global state explicit in testcase generators The quicksort-killer testcase will require more global state, unless we go to the effort of implementing qsort_r versions of all the sorting algorithms. Since we're not doing that, we'll simply make the global state explicit. --- bench.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bench.c') diff --git a/bench.c b/bench.c index e0629b2..75bf32e 100644 --- a/bench.c +++ b/bench.c @@ -34,14 +34,14 @@ int main() printf("%-*s ", SORT_WIDTH, size == MIN_SIZE ? s->name : ""); for (const struct testcase *t = testcases; t->name; t++) { comparisons = 0; - t->init(buffer, size); + 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)); - assert_sorted(buffer, size); + assert_sorted(size, t->cmp); } printf(" %*zu\n", SIZE_WIDTH, size); } -- cgit v1.2.3