about summary refs log tree commit diff
path: root/benchtests
diff options
context:
space:
mode:
authorWilco Dijkstra <wilco.dijkstra@arm.com>2023-03-03 13:03:19 +0000
committerWilco Dijkstra <wilco.dijkstra@arm.com>2023-03-08 18:36:48 +0000
commit5de1508803bd1beeadd370ebac19e43b3232380b (patch)
tree763df389ac94b44743b13da43f3bc4d96a13bf2d /benchtests
parentb0e02d5b6d65cdfc972494484ef9a67b8e55e8f0 (diff)
downloadglibc-5de1508803bd1beeadd370ebac19e43b3232380b.tar.gz
glibc-5de1508803bd1beeadd370ebac19e43b3232380b.tar.xz
glibc-5de1508803bd1beeadd370ebac19e43b3232380b.zip
Benchtests: Remove simple_strcspn/strpbrk/strsep
Remove simple_strcspn/strpbrk/strsep which are significantly slower than the
generic implementations.  Also remove oldstrsep and oldstrtok since they are
practically identical to the generic implementation.  Adjust iteration count
to reduce benchmark time.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'benchtests')
-rw-r--r--benchtests/bench-strcspn.c21
-rw-r--r--benchtests/bench-strpbrk.c23
-rw-r--r--benchtests/bench-strsep.c78
-rw-r--r--benchtests/bench-strspn.c23
-rw-r--r--benchtests/bench-strtok.c36
5 files changed, 4 insertions, 177 deletions
diff --git a/benchtests/bench-strcspn.c b/benchtests/bench-strcspn.c
index 2388f33d54..fa74d305ae 100644
--- a/benchtests/bench-strcspn.c
+++ b/benchtests/bench-strcspn.c
@@ -26,29 +26,8 @@
 #endif /* WIDE */
 #include "bench-string.h"
 
-#ifndef WIDE
-# define SIMPLE_STRCSPN simple_strcspn
-#else
-# define SIMPLE_STRCSPN simple_wcscspn
-#endif /* WIDE */
-
 typedef size_t (*proto_t) (const CHAR *, const CHAR *);
-size_t SIMPLE_STRCSPN (const CHAR *, const CHAR *);
 
-IMPL (SIMPLE_STRCSPN, 0)
 IMPL (STRCSPN, 1)
 
-size_t
-SIMPLE_STRCSPN (const CHAR *s, const CHAR *rej)
-{
-  const CHAR *r, *str = s;
-  CHAR c;
-
-  while ((c = *s++) != '\0')
-    for (r = rej; *r != '\0'; ++r)
-      if (*r == c)
-	return s - str - 1;
-  return s - str - 1;
-}
-
 #include "bench-strpbrk.c"
diff --git a/benchtests/bench-strpbrk.c b/benchtests/bench-strpbrk.c
index e96fb0efbf..55199b73c9 100644
--- a/benchtests/bench-strpbrk.c
+++ b/benchtests/bench-strpbrk.c
@@ -35,31 +35,10 @@
 # endif /* WIDE */
 # include "bench-string.h"
 
-# ifndef WIDE
-#  define SIMPLE_STRPBRK simple_strpbrk
-# else
-#  define SIMPLE_STRPBRK simple_wcspbrk
-# endif /* WIDE */
-
 typedef CHAR *(*proto_t) (const CHAR *, const CHAR *);
-CHAR *SIMPLE_STRPBRK (const CHAR *, const CHAR *);
 
-IMPL (SIMPLE_STRPBRK, 0)
 IMPL (STRPBRK, 1)
 
-CHAR *
-SIMPLE_STRPBRK (const CHAR *s, const CHAR *rej)
-{
-  const CHAR *r;
-  CHAR c;
-
-  while ((c = *s++) != '\0')
-    for (r = rej; *r != '\0'; ++r)
-      if (*r == c)
-	return (CHAR *) s - 1;
-  return NULL;
-}
-
 #endif /* !STRPBRK_RESULT */
 
 #include "json-lib.h"
@@ -69,7 +48,7 @@ do_one_test (json_ctx_t *json_ctx, 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_ITERS8 / CHARBYTES;
   timing_t start, stop, cur;
 
   if (res != exp_res)
diff --git a/benchtests/bench-strsep.c b/benchtests/bench-strsep.c
index 4b203aff30..d7df3fa0a9 100644
--- a/benchtests/bench-strsep.c
+++ b/benchtests/bench-strsep.c
@@ -20,90 +20,14 @@
 #define TEST_NAME "strsep"
 #include "bench-string.h"
 
-char *
-simple_strsep (char **s1, char *s2)
-{
-  char *begin;
-  char *s;
-  size_t j = 0;
-
-  begin = *s1;
-  s = begin;
-  if (begin == NULL)
-    return NULL;
-  ssize_t s2len = strlen (s2);
-  while (*s)
-    {
-      for (j = 0; j < s2len; j++)
-	{
-	  if (*s == s2[j])
-	    {
-	      s[0] = '\0';
-	      *s1 = s + 1;
-	      return begin;
-	    }
-	}
-      s++;
-    }
-  *s1 = NULL;
-  return begin;
-}
-
-char *
-oldstrsep (char **stringp, const char *delim)
-{
-  char *begin, *end;
-
-  begin = *stringp;
-  if (begin == NULL)
-    return NULL;
-
-  /* A frequent case is when the delimiter string contains only one
-     character.  Here we don't need to call the expensive `strpbrk'
-     function and instead work using `strchr'.  */
-  if (delim[0] == '\0' || delim[1] == '\0')
-    {
-      char ch = delim[0];
-
-      if (ch == '\0')
-	end = NULL;
-      else
-	{
-	  if (*begin == ch)
-	    end = begin;
-	  else if (*begin == '\0')
-	    end = NULL;
-	  else
-	    end = strchr (begin + 1, ch);
-	}
-    }
-  else
-    /* Find the end of the token.  */
-    end = strpbrk (begin, delim);
-
-  if (end)
-    {
-      /* Terminate the token and set *STRINGP past NUL character.  */
-      *end++ = '\0';
-      *stringp = end;
-    }
-  else
-    /* No more delimiters; this is the last token.  */
-    *stringp = NULL;
-
-  return begin;
-}
-
 typedef char *(*proto_t) (const char **, const char *);
 
-IMPL (simple_strsep, 0)
 IMPL (strsep, 1)
-IMPL (oldstrsep, 2)
 
 static void
 do_one_test (impl_t * impl, const char *s1, const char *s2)
 {
-  size_t i, iters = INNER_LOOP_ITERS_SMALL;
+  size_t i, iters = INNER_LOOP_ITERS;
   timing_t start, stop, cur;
 
   TIMING_NOW (start);
diff --git a/benchtests/bench-strspn.c b/benchtests/bench-strspn.c
index 707613cbcf..cc98ffb38b 100644
--- a/benchtests/bench-strspn.c
+++ b/benchtests/bench-strspn.c
@@ -28,41 +28,20 @@
 #define BIG_CHAR MAX_CHAR
 
 #ifndef WIDE
-# define SIMPLE_STRSPN simple_strspn
 # define SMALL_CHAR 127
 #else
-# define SIMPLE_STRSPN simple_wcsspn
 # define SMALL_CHAR 1273
 #endif /* WIDE */
 
 typedef size_t (*proto_t) (const CHAR *, const CHAR *);
-size_t SIMPLE_STRSPN (const CHAR *, const CHAR *);
 
-IMPL (SIMPLE_STRSPN, 0)
 IMPL (STRSPN, 1)
 
-size_t
-SIMPLE_STRSPN (const CHAR *s, const CHAR *acc)
-{
-  const CHAR *r, *str = s;
-  CHAR c;
-
-  while ((c = *s++) != '\0')
-    {
-      for (r = acc; *r != '\0'; ++r)
-	if (*r == c)
-	  break;
-      if (*r == '\0')
-	return s - str - 1;
-    }
-  return s - str - 1;
-}
-
 static void
 do_one_test (json_ctx_t *json_ctx, 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_ITERS8 / CHARBYTES;
   timing_t start, stop, cur;
 
   if (res != exp_res)
diff --git a/benchtests/bench-strtok.c b/benchtests/bench-strtok.c
index 711bdaab58..b5789d7bf2 100644
--- a/benchtests/bench-strtok.c
+++ b/benchtests/bench-strtok.c
@@ -20,47 +20,14 @@
 #define TEST_NAME "strtok"
 #include "bench-string.h"
 
-char *
-oldstrtok (char *s, const char *delim)
-{
-  static char *olds;
-  char *token;
-
-  if (s == NULL)
-    s = olds;
-
-  /* Scan leading delimiters.  */
-  s += strspn (s, delim);
-  if (*s == '\0')
-    {
-      olds = s;
-      return NULL;
-    }
-
-  /* Find the end of the token.  */
-  token = s;
-  s = strpbrk (token, delim);
-  if (s == NULL)
-    /* This token finishes the string.  */
-    olds = strchr (token, '\0');
-  else
-    {
-      /* Terminate the token and make OLDS point past it.  */
-      *s = '\0';
-      olds = s + 1;
-    }
-  return token;
-}
-
 typedef char *(*proto_t) (const char *, const char *);
 
-IMPL (oldstrtok, 0)
 IMPL (strtok, 1)
 
 static void
 do_one_test (impl_t * impl, const char *s1, const char *s2)
 {
-  size_t i, iters = INNER_LOOP_ITERS_SMALL;
+  size_t i, iters = INNER_LOOP_ITERS_MEDIUM;
   timing_t start, stop, cur;
   TIMING_NOW (start);
   for (i = 0; i < iters; ++i)
@@ -74,7 +41,6 @@ do_one_test (impl_t * impl, const char *s1, const char *s2)
   TIMING_DIFF (cur, start, stop);
 
   TIMING_PRINT_MEAN ((double) cur, (double) iters);
-
 }