From 2623479105a7e11ccd1e504b3f549cadbb875a42 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Tue, 21 Mar 2023 14:00:22 +0000 Subject: [PATCH] Benchtests: Adjust timing Adjust iteration counts so benchmarks don't run too slowly or quickly. Ensure benchmarks take less than 10 seconds on older, slower cores and more than 0.5 seconds on fast cores. Reviewed-by: Adhemerval Zanella --- benchtests/bench-bzero.c | 2 +- benchtests/bench-hash-funcs.c | 2 +- benchtests/bench-memccpy.c | 2 +- benchtests/bench-memchr.c | 2 +- benchtests/bench-memcpy-random.c | 2 +- benchtests/bench-memcpy.c | 2 +- benchtests/bench-memset.c | 2 +- benchtests/bench-strcat.c | 2 +- benchtests/bench-strcmp.c | 2 +- benchtests/bench-strlen.c | 2 +- benchtests/bench-strncpy.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/benchtests/bench-bzero.c b/benchtests/bench-bzero.c index 7ff04f2..5e891ce 100644 --- a/benchtests/bench-bzero.c +++ b/benchtests/bench-bzero.c @@ -51,7 +51,7 @@ IMPL (memset_zero, 0) static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, size_t n) { - size_t i, iters = INNER_LOOP_ITERS_LARGE; + size_t i, iters = INNER_LOOP_ITERS8; timing_t start, stop, cur; TIMING_NOW (start); diff --git a/benchtests/bench-hash-funcs.c b/benchtests/bench-hash-funcs.c index 5e7e502..4a6858c 100644 --- a/benchtests/bench-hash-funcs.c +++ b/benchtests/bench-hash-funcs.c @@ -42,7 +42,7 @@ enum { NFIXED_ITERS = 1048576, NRAND_BUFS = 16384, - NRAND_ITERS = 2048, + NRAND_ITERS = 256, RAND_BENCH_MAX_LEN = 128 }; diff --git a/benchtests/bench-memccpy.c b/benchtests/bench-memccpy.c index 51ed8da..a26ed7e 100644 --- a/benchtests/bench-memccpy.c +++ b/benchtests/bench-memccpy.c @@ -41,7 +41,7 @@ static void do_one_test (impl_t *impl, void *dst, const void *src, int c, size_t len, size_t n) { - size_t i, iters = INNER_LOOP_ITERS_LARGE; + size_t i, iters = INNER_LOOP_ITERS_LARGE * 4; timing_t start, stop, cur; TIMING_NOW (start); diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c index 90bd387..1a9bf51 100644 --- a/benchtests/bench-memchr.c +++ b/benchtests/bench-memchr.c @@ -51,7 +51,7 @@ static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, int c, size_t n) { - size_t i, iters = INNER_LOOP_ITERS; + size_t i, iters = INNER_LOOP_ITERS8 / 2; timing_t start, stop, cur; TIMING_NOW (start); diff --git a/benchtests/bench-memcpy-random.c b/benchtests/bench-memcpy-random.c index a0753b6..48cb64d 100644 --- a/benchtests/bench-memcpy-random.c +++ b/benchtests/bench-memcpy-random.c @@ -127,7 +127,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, copy_t *copy, size_t n) { timing_t start, stop, cur; - size_t iters = INNER_LOOP_ITERS_MEDIUM; + size_t iters = INNER_LOOP_ITERS_MEDIUM / 2; for (int j = 0; j < n; j++) CALL (impl, dst + copy[j].dst, src + copy[j].src, copy[j].len); diff --git a/benchtests/bench-memcpy.c b/benchtests/bench-memcpy.c index 1fd41c0..5be0996 100644 --- a/benchtests/bench-memcpy.c +++ b/benchtests/bench-memcpy.c @@ -38,7 +38,7 @@ static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, const char *src, size_t len) { - size_t i, iters = INNER_LOOP_ITERS; + size_t i, iters = INNER_LOOP_ITERS / 2; timing_t start, stop, cur; for (i = 0; i < iters / 64; ++i) { diff --git a/benchtests/bench-memset.c b/benchtests/bench-memset.c index 1e785e6..e68b142 100644 --- a/benchtests/bench-memset.c +++ b/benchtests/bench-memset.c @@ -43,7 +43,7 @@ static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n) { - size_t i, iters = INNER_LOOP_ITERS_LARGE; + size_t i, iters = INNER_LOOP_ITERS; timing_t start, stop, cur; TIMING_NOW (start); diff --git a/benchtests/bench-strcat.c b/benchtests/bench-strcat.c index 96383ce..08a19e5 100644 --- a/benchtests/bench-strcat.c +++ b/benchtests/bench-strcat.c @@ -52,7 +52,7 @@ IMPL (generic_strcat, 0) static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *dst, const CHAR *src) { - size_t k = STRLEN (dst), i, iters = INNER_LOOP_ITERS_LARGE; + size_t k = STRLEN (dst), i, iters = INNER_LOOP_ITERS_LARGE / CHARBYTES; timing_t start, stop, cur; if (CALL (impl, dst, src) != dst) diff --git a/benchtests/bench-strcmp.c b/benchtests/bench-strcmp.c index 65fd04b..f696f07 100644 --- a/benchtests/bench-strcmp.c +++ b/benchtests/bench-strcmp.c @@ -50,7 +50,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1, const CHAR *s2, int exp_result) { - size_t i, iters = INNER_LOOP_ITERS; + size_t i, iters = INNER_LOOP_ITERS8 / 2; timing_t start, stop, cur; TIMING_NOW (start); diff --git a/benchtests/bench-strlen.c b/benchtests/bench-strlen.c index 9b91f8a..cae88dd 100644 --- a/benchtests/bench-strlen.c +++ b/benchtests/bench-strlen.c @@ -48,7 +48,7 @@ IMPL (STRLEN, 1) static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, size_t exp_len) { - size_t len = CALL (impl, s), i, iters = INNER_LOOP_ITERS8; + size_t len = CALL (impl, s), i, iters = INNER_LOOP_ITERS_LARGE; timing_t start, stop, cur; if (len != exp_len) diff --git a/benchtests/bench-strncpy.c b/benchtests/bench-strncpy.c index 83a88f6..d90e3c5 100644 --- a/benchtests/bench-strncpy.c +++ b/benchtests/bench-strncpy.c @@ -57,7 +57,7 @@ static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *dst, const CHAR *src, size_t len, size_t n) { - size_t i, iters = INNER_LOOP_ITERS_LARGE * (4 / CHARBYTES); + size_t i, iters = INNER_LOOP_ITERS_LARGE / CHARBYTES; timing_t start, stop, cur; if (CALL (impl, dst, src, n) != STRNCPY_RESULT (dst, len, n)) -- 2.7.4