about summary refs log tree commit diff
path: root/benchtests/bench-strrchr.c
diff options
context:
space:
mode:
authorWilco Dijkstra <wilco.dijkstra@arm.com>2023-03-03 16:10:55 +0000
committerWilco Dijkstra <wilco.dijkstra@arm.com>2023-03-08 18:36:48 +0000
commit10f980d31e3d65c4c5bfafd176e7e1db92e2babe (patch)
tree8e86b6c4cc0e6709b7a6a07af7732c6247231884 /benchtests/bench-strrchr.c
parent9ab7c42387409d5cf8facd0a56cfd98ce55b8cc3 (diff)
downloadglibc-10f980d31e3d65c4c5bfafd176e7e1db92e2babe.tar.gz
glibc-10f980d31e3d65c4c5bfafd176e7e1db92e2babe.tar.xz
glibc-10f980d31e3d65c4c5bfafd176e7e1db92e2babe.zip
Benchtests: Remove simple_str(r)chr
Instead of benchmarking slow byte oriented loops, include the optimized generic
strchr and strrchr implementation.  Adjust iteration count to reduce benchmark
time.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'benchtests/bench-strrchr.c')
-rw-r--r--benchtests/bench-strrchr.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/benchtests/bench-strrchr.c b/benchtests/bench-strrchr.c
index a33a657a27..f846797770 100644
--- a/benchtests/bench-strrchr.c
+++ b/benchtests/bench-strrchr.c
@@ -28,30 +28,20 @@
 #define BIG_CHAR MAX_CHAR
 
 #ifdef WIDE
-# define SIMPLE_STRRCHR simple_wcsrchr
 # define SMALL_CHAR 1273
 #else
-# define SIMPLE_STRRCHR simple_strrchr
 # define SMALL_CHAR 127
-#endif
 
-typedef CHAR *(*proto_t) (const CHAR *, int);
-CHAR *SIMPLE_STRRCHR (const CHAR *, int);
+char *
+generic_strrchr (const char *, int);
 
-IMPL (SIMPLE_STRRCHR, 0)
-IMPL (STRRCHR, 1)
+IMPL (generic_strrchr, 0)
 
-CHAR *
-SIMPLE_STRRCHR (const CHAR *s, int c)
-{
-  const CHAR *ret = NULL;
+#endif
 
-  for (; *s != '\0'; ++s)
-    if (*s == (CHAR) c)
-      ret = s;
+typedef CHAR *(*proto_t) (const CHAR *, int);
 
-  return (CHAR *) (c == '\0' ? s : ret);
-}
+IMPL (STRRCHR, 1)
 
 static void
 do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, int c,
@@ -237,3 +227,12 @@ test_main (void)
 }
 
 #include <support/test-driver.c>
+
+#define weak_alias(X,Y)
+#define libc_hidden_builtin_def(X)
+#ifndef WIDE
+# undef STRRCHR
+# define STRRCHR generic_strrchr
+# define __memrchr memrchr
+# include <string/strrchr.c>
+#endif