diff options
Diffstat (limited to 'benchtests/bench-strchr.c')
-rw-r--r-- | benchtests/bench-strchr.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c index 710b59203d..d432ba53b8 100644 --- a/benchtests/bench-strchr.c +++ b/benchtests/bench-strchr.c @@ -89,23 +89,19 @@ IMPL (STRCHR, 1) static void do_one_test (impl_t *impl, const CHAR *s, int c, const CHAR *exp_res) { - 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; - - for (i = 0; i < 32; ++i) - { - HP_TIMING_NOW (start); - CALL (impl, s, c); - HP_TIMING_NOW (stop); - HP_TIMING_BEST (best_time, start, stop); - } - - printf ("\t%zd", (size_t) best_time); + CALL (impl, s, c); } + TIMING_NOW (stop); + + TIMING_DIFF (cur, start, stop); + + TIMING_PRINT_MEAN ((double) cur, (double) iters); } static void @@ -141,15 +137,13 @@ do_test (size_t align, size_t pos, size_t len, int seek_char, int max_char) else result = NULLRET (buf + align + len); - if (HP_TIMING_AVAIL) - printf ("Length %4zd, alignment in bytes %2zd:", - pos, align * sizeof (CHAR)); + printf ("Length %4zd, alignment in bytes %2zd:", + pos, align * sizeof (CHAR)); FOR_EACH_IMPL (impl, 0) do_one_test (impl, buf + align, seek_char, result); - if (HP_TIMING_AVAIL) - putchar ('\n'); + putchar ('\n'); } int |