summaryrefslogtreecommitdiff
path: root/benchtests/bench-memchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'benchtests/bench-memchr.c')
-rw-r--r--benchtests/bench-memchr.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/benchtests/bench-memchr.c b/benchtests/bench-memchr.c
index aa012f2910..2603cdca99 100644
--- a/benchtests/bench-memchr.c
+++ b/benchtests/bench-memchr.c
@@ -1,5 +1,5 @@
/* Measure memchr functions.
- Copyright (C) 2013-2016 Free Software Foundation, Inc.
+ Copyright (C) 2013-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -59,20 +59,11 @@ SIMPLE_MEMCHR (const CHAR *s, int c, size_t n)
#endif /* !USE_AS_MEMRCHR */
static void
-do_one_test (impl_t *impl, const CHAR *s, int c, size_t n, CHAR *exp_res)
+do_one_test (impl_t *impl, const CHAR *s, int c, size_t n)
{
- CHAR *res = CALL (impl, s, c, n);
size_t i, iters = INNER_LOOP_ITERS;
timing_t start, stop, cur;
- if (res != exp_res)
- {
- error (0, 0, "Wrong result in function %s %p %p", impl->name,
- res, exp_res);
- ret = 1;
- return;
- }
-
TIMING_NOW (start);
for (i = 0; i < iters; ++i)
{
@@ -89,7 +80,6 @@ static void
do_test (size_t align, size_t pos, size_t len, int seek_char)
{
size_t i;
- CHAR *result;
align &= 7;
if ((align + len) * sizeof (CHAR) >= page_size)
@@ -109,18 +99,17 @@ do_test (size_t align, size_t pos, size_t len, int seek_char)
{
buf[align + pos] = seek_char;
buf[align + len] = -seek_char;
- result = (CHAR *) (buf + align + pos);
}
else
{
- result = NULL;
buf[align + len] = seek_char;
}
- printf ("Length %4zd, alignment %2zd:", pos, align);
+ printf ("Length %4zd, position %4zd, alignment %2zd:",
+ len, pos, align);
FOR_EACH_IMPL (impl, 0)
- do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result);
+ do_one_test (impl, (CHAR *) (buf + align), seek_char, len);
putchar ('\n');
}
@@ -143,14 +132,28 @@ test_main (void)
do_test (i, 64, 256, 23);
do_test (0, 16 << i, 2048, 0);
do_test (i, 64, 256, 0);
+#ifdef USE_AS_MEMRCHR
+ /* Also test the position close to the beginning for memrchr. */
+ do_test (0, i, 256, 23);
+ do_test (0, i, 256, 0);
+ do_test (i, i, 256, 23);
+ do_test (i, i, 256, 0);
+#endif
}
for (i = 1; i < 32; ++i)
{
do_test (0, i, i + 1, 23);
do_test (0, i, i + 1, 0);
+ do_test (i, i, i + 1, 23);
+ do_test (i, i, i + 1, 0);
+#ifdef USE_AS_MEMRCHR
+ /* Also test the position close to the beginning for memrchr. */
+ do_test (0, 1, i + 1, 23);
+ do_test (0, 2, i + 1, 0);
+#endif
}
return ret;
}
-#include "../test-skeleton.c"
+#include <support/test-driver.c>