diff options
Diffstat (limited to 'benchtests/bench-memmem.c')
-rw-r--r-- | benchtests/bench-memmem.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/benchtests/bench-memmem.c b/benchtests/bench-memmem.c index ca758a84f2..b8f8a8b2a3 100644 --- a/benchtests/bench-memmem.c +++ b/benchtests/bench-memmem.c @@ -60,23 +60,19 @@ static void do_one_test (impl_t *impl, const void *haystack, size_t haystack_len, const void *needle, size_t needle_len, const void *expected) { - if (HP_TIMING_AVAIL) + size_t i, iters = INNER_LOOP_ITERS; + timing_t start, stop, cur; + + TIMING_NOW (start); + for (i = 0; i < iters; ++i) { - hp_timing_t start __attribute ((unused)); - hp_timing_t stop __attribute ((unused)); - hp_timing_t best_time = ~ (hp_timing_t) 0; - size_t i; + CALL (impl, haystack, haystack_len, needle, needle_len); + } + TIMING_NOW (stop); - for (i = 0; i < 32; ++i) - { - HP_TIMING_NOW (start); - CALL (impl, haystack, haystack_len, needle, needle_len); - HP_TIMING_NOW (stop); - HP_TIMING_BEST (best_time, start, stop); - } + TIMING_DIFF (cur, start, stop); - printf ("\t%zd", (size_t) best_time); - } + TIMING_PRINT_MEAN ((double) cur, (double) iters); } static void @@ -87,16 +83,14 @@ do_test (const char *str, size_t len, size_t idx) memcpy (tmpbuf, buf1 + idx, len); memcpy (buf1 + idx, str, len); - if (HP_TIMING_AVAIL) - printf ("String %s, offset %zd:", str, idx); + printf ("String %s, offset %zd:", str, idx); FOR_EACH_IMPL (impl, 0) do_one_test (impl, buf1, BUF1PAGES * page_size, str, len, buf1 + idx); memcpy (buf1 + idx, tmpbuf, len); - if (HP_TIMING_AVAIL) - putchar ('\n'); + putchar ('\n'); } static void @@ -120,15 +114,13 @@ do_random_tests (void) buf1[idx + off] = ch; } - if (HP_TIMING_AVAIL) - printf ("String %.*s, offset %zd:", (int) len, buf1 + idx, idx); + printf ("String %.*s, offset %zd:", (int) len, buf1 + idx, idx); FOR_EACH_IMPL (impl, 0) do_one_test (impl, buf1, BUF1PAGES * page_size, buf1 + idx, len, buf1 + idx); - if (HP_TIMING_AVAIL) - putchar ('\n'); + putchar ('\n'); memcpy (buf1 + idx, tmpbuf, len); } |