]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - benchtests/bench-rawmemchr.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / benchtests / bench-rawmemchr.c
index 9a2c00a9303fae6d20e9b87c2fff5f2a496482ce..d45a2b815dd4f576145e3c3da3f8637ea44adc76 100644 (file)
@@ -1,5 +1,5 @@
 /* Measure memchr functions.
-   Copyright (C) 2013-2017 Free Software Foundation, Inc.
+   Copyright (C) 2013-2019 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
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #include <assert.h>
+#include <stdint.h>
 
 #define TEST_MAIN
 #define TEST_NAME "rawmemchr"
 #include "bench-string.h"
 
 typedef char *(*proto_t) (const char *, int);
-char *simple_rawmemchr (const char *, int);
-
-IMPL (simple_rawmemchr, 0)
-IMPL (rawmemchr, 1)
 
 char *
-simple_rawmemchr (const char *s, int c)
+generic_rawmemchr (const char *s, int c)
 {
-  while (1)
-    if (*s++ == (char) c)
-      return (char *) s - 1;
-  return NULL;
+  if (c != 0)
+    return memchr (s, c, PTRDIFF_MAX);
+  return (char *)s + strlen (s);
 }
 
+IMPL (rawmemchr, 1)
+IMPL (generic_rawmemchr, 0)
+
 static void
 do_one_test (impl_t *impl, const char *s, int c, char *exp_res)
 {
-  size_t i, iters = INNER_LOOP_ITERS;
+  size_t i, iters = INNER_LOOP_ITERS_LARGE * 4;
   timing_t start, stop, cur;
   char *res = CALL (impl, s, c);
   if (res != exp_res)