aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2019-05-21 15:19:06 +0100
committerWilco Dijkstra <wdijkstr@arm.com>2019-05-21 15:19:06 +0100
commit46ae07324b1cd50fbf8f37a076d6babcfca7c510 (patch)
treee8780d68dd3c13c83a7face67d7e69a6902a8b6b /benchtests
parentsysvipc: Add missing bit of semtimedop s390 consolidation (diff)
downloadglibc-46ae07324b1cd50fbf8f37a076d6babcfca7c510.tar.gz
glibc-46ae07324b1cd50fbf8f37a076d6babcfca7c510.tar.bz2
glibc-46ae07324b1cd50fbf8f37a076d6babcfca7c510.zip
Improve string benchtest timing
Improve string benchtest timing. Many tests run for 0.01s which is way too short to give accurate results. Other tests take over 40 seconds which is way too long. Significantly increase the iterations of the short running tests. Reduce number of alignment variations in the long running memcpy walk tests so they take less than 5 seconds. As a result most tests take at least 0.1s and all finish within 5 seconds. * benchtests/bench-memcpy-random.c (do_one_test): Use medium iterations. * benchtests/bench-memcpy-walk.c (test_main): Reduce alignment tests. * benchtests/bench-memmem.c (do_one_test): Use small iterations. * benchtests/bench-memmove-walk.c (test_main): Reduce alignment tests. * benchtests/bench-memset-walk.c (test_main): Reduce alignment tests. * benchtests/bench-strcasestr.c (do_one_test): Use small iterations. * benchtests/bench-string.h (INNER_LOOP_ITERS): Increase iterations. (INNER_LOOP_ITERS_MEDIUM): New define. (INNER_LOOP_ITERS_SMALL): New define. * benchtests/bench-strpbrk.c (do_one_test): Use medium iterations. * benchtests/bench-strsep.c (do_one_test): Use small iterations. * benchtests/bench-strspn.c (do_one_test): Use medium iterations. * benchtests/bench-strstr.c (do_one_test): Use small iterations. * benchtests/bench-strtok.c (do_one_test): Use small iterations.
Diffstat (limited to 'benchtests')
-rw-r--r--benchtests/bench-memcpy-random.c2
-rw-r--r--benchtests/bench-memcpy-walk.c8
-rw-r--r--benchtests/bench-memmem.c2
-rw-r--r--benchtests/bench-memmove-walk.c16
-rw-r--r--benchtests/bench-memset-walk.c13
-rw-r--r--benchtests/bench-strcasestr.c2
-rw-r--r--benchtests/bench-string.h4
-rw-r--r--benchtests/bench-strpbrk.c2
-rw-r--r--benchtests/bench-strsep.c2
-rw-r--r--benchtests/bench-strspn.c2
-rw-r--r--benchtests/bench-strstr.c2
-rw-r--r--benchtests/bench-strtok.c2
12 files changed, 25 insertions, 32 deletions
diff --git a/benchtests/bench-memcpy-random.c b/benchtests/bench-memcpy-random.c
index 873133d9a6..f2c2e9dc3d 100644
--- a/benchtests/bench-memcpy-random.c
+++ b/benchtests/bench-memcpy-random.c
@@ -101,7 +101,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 * 20;
+ size_t iters = INNER_LOOP_ITERS_MEDIUM;
TIMING_NOW (start);
for (int i = 0; i < iters; ++i)
diff --git a/benchtests/bench-memcpy-walk.c b/benchtests/bench-memcpy-walk.c
index 16b455f779..397a1e98df 100644
--- a/benchtests/bench-memcpy-walk.c
+++ b/benchtests/bench-memcpy-walk.c
@@ -103,12 +103,8 @@ test_main (void)
json_array_begin (&json_ctx, "results");
for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
{
- /* Test length alignments from 0-16 bytes. */
- for (int j = 0; j < 8; j++)
- {
- do_test (&json_ctx, i + j);
- do_test (&json_ctx, i + 16 - j);
- }
+ do_test (&json_ctx, i);
+ do_test (&json_ctx, i + 1);
}
json_array_end (&json_ctx);
diff --git a/benchtests/bench-memmem.c b/benchtests/bench-memmem.c
index b6b97f3d1f..42778b0765 100644
--- a/benchtests/bench-memmem.c
+++ b/benchtests/bench-memmem.c
@@ -105,7 +105,7 @@ 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)
{
- size_t i, iters = INNER_LOOP_ITERS;
+ size_t i, iters = INNER_LOOP_ITERS_SMALL;
timing_t start, stop, cur;
TIMING_NOW (start);
diff --git a/benchtests/bench-memmove-walk.c b/benchtests/bench-memmove-walk.c
index 7b4c31e63f..2b4a7e4f29 100644
--- a/benchtests/bench-memmove-walk.c
+++ b/benchtests/bench-memmove-walk.c
@@ -107,23 +107,15 @@ test_main (void)
/* Non-overlapping buffers. */
for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
{
- /* Test length alignments from 0-16 bytes. */
- for (int j = 0; j < 8; j++)
- {
- do_test (&json_ctx, i + j, false);
- do_test (&json_ctx, i + 16 - j, false);
- }
+ do_test (&json_ctx, i, false);
+ do_test (&json_ctx, i + 1, false);
}
/* Overlapping buffers. */
for (size_t i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
{
- /* Test length alignments from 0-16 bytes. */
- for (int j = 0; j < 8; j++)
- {
- do_test (&json_ctx, i + j, true);
- do_test (&json_ctx, i + 16 - j, true);
- }
+ do_test (&json_ctx, i, true);
+ do_test (&json_ctx, i + 1, true);
}
json_array_end (&json_ctx);
diff --git a/benchtests/bench-memset-walk.c b/benchtests/bench-memset-walk.c
index 5f43671216..930aae34d1 100644
--- a/benchtests/bench-memset-walk.c
+++ b/benchtests/bench-memset-walk.c
@@ -112,13 +112,16 @@ test_main (void)
json_array_begin (&json_ctx, "results");
for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
- /* Test length alignments from 0-16 bytes. */
- for (int j = 0; j < i && j < 16; j++)
- do_test (&json_ctx, 65, i + j);
+ {
+ do_test (&json_ctx, 65, i);
+ do_test (&json_ctx, 65, i + 1);
+ }
for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
- for (int j = 0; j < i && j < 16; j++)
- do_test (&json_ctx, 0, i + j);
+ {
+ do_test (&json_ctx, 0, i);
+ do_test (&json_ctx, 0, i + 1);
+ }
json_array_end (&json_ctx);
json_attr_object_end (&json_ctx);
diff --git a/benchtests/bench-strcasestr.c b/benchtests/bench-strcasestr.c
index 1458070d47..d701ff4f36 100644
--- a/benchtests/bench-strcasestr.c
+++ b/benchtests/bench-strcasestr.c
@@ -36,7 +36,7 @@ IMPL (strcasestr, 1)
static void
do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
{
- size_t i, iters = INNER_LOOP_ITERS;
+ size_t i, iters = INNER_LOOP_ITERS_SMALL;
timing_t start, stop, cur;
TIMING_NOW (start);
diff --git a/benchtests/bench-string.h b/benchtests/bench-string.h
index 9d3332a624..e7fb015bc6 100644
--- a/benchtests/bench-string.h
+++ b/benchtests/bench-string.h
@@ -124,7 +124,9 @@ extern impl_t __start_impls[], __stop_impls[];
# define OPT_RANDOM 10001
# define OPT_SEED 10002
-# define INNER_LOOP_ITERS 64
+# define INNER_LOOP_ITERS 8192
+# define INNER_LOOP_ITERS_MEDIUM 1024
+# define INNER_LOOP_ITERS_SMALL 32
int ret, do_srandom;
unsigned int seed;
diff --git a/benchtests/bench-strpbrk.c b/benchtests/bench-strpbrk.c
index 14e1bcb873..e484ebd0c0 100644
--- a/benchtests/bench-strpbrk.c
+++ b/benchtests/bench-strpbrk.c
@@ -66,7 +66,7 @@ static void
do_one_test (impl_t *impl, const CHAR *s, const CHAR *rej, RES_TYPE exp_res)
{
RES_TYPE res = CALL (impl, s, rej);
- size_t i, iters = INNER_LOOP_ITERS;
+ size_t i, iters = INNER_LOOP_ITERS_MEDIUM;
timing_t start, stop, cur;
if (res != exp_res)
diff --git a/benchtests/bench-strsep.c b/benchtests/bench-strsep.c
index fea7fbdfa6..96d3be5222 100644
--- a/benchtests/bench-strsep.c
+++ b/benchtests/bench-strsep.c
@@ -103,7 +103,7 @@ IMPL (oldstrsep, 2)
static void
do_one_test (impl_t * impl, const char *s1, const char *s2)
{
- size_t i, iters = INNER_LOOP_ITERS;
+ size_t i, iters = INNER_LOOP_ITERS_SMALL;
timing_t start, stop, cur;
TIMING_NOW (start);
diff --git a/benchtests/bench-strspn.c b/benchtests/bench-strspn.c
index ac874fe234..ed97c5fc62 100644
--- a/benchtests/bench-strspn.c
+++ b/benchtests/bench-strspn.c
@@ -60,7 +60,7 @@ SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
static void
do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res)
{
- size_t res = CALL (impl, s, acc), i, iters = INNER_LOOP_ITERS;
+ size_t res = CALL (impl, s, acc), i, iters = INNER_LOOP_ITERS_MEDIUM;
timing_t start, stop, cur;
if (res != exp_res)
diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c
index 31309b2402..b4cd141083 100644
--- a/benchtests/bench-strstr.c
+++ b/benchtests/bench-strstr.c
@@ -131,7 +131,7 @@ IMPL (basic_strstr, 0)
static void
do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
{
- size_t i, iters = INNER_LOOP_ITERS;
+ size_t i, iters = INNER_LOOP_ITERS_SMALL;
timing_t start, stop, cur;
char *res;
diff --git a/benchtests/bench-strtok.c b/benchtests/bench-strtok.c
index 15ae76e237..f5ab587dd9 100644
--- a/benchtests/bench-strtok.c
+++ b/benchtests/bench-strtok.c
@@ -60,7 +60,7 @@ IMPL (strtok, 1)
static void
do_one_test (impl_t * impl, const char *s1, const char *s2)
{
- size_t i, iters = INNER_LOOP_ITERS;
+ size_t i, iters = INNER_LOOP_ITERS_SMALL;
timing_t start, stop, cur;
TIMING_NOW (start);
for (i = 0; i < iters; ++i)