about summary refs log tree commit diff
path: root/benchtests/bench-strtok.c
diff options
context:
space:
mode:
authorOndřej Bílka <neleai@seznam.cz>2014-02-28 22:45:33 +0100
committerOndřej Bílka <neleai@seznam.cz>2014-02-28 22:45:33 +0100
commit7b3551e3a8f7278e123757987570c72f1216acc2 (patch)
treeede731662ee3de3bfa4f9da72edea4e3d1cbc76f /benchtests/bench-strtok.c
parentf08e9a26299db1972cb29a7e84b40b0cc9866bf2 (diff)
downloadglibc-7b3551e3a8f7278e123757987570c72f1216acc2.tar.gz
glibc-7b3551e3a8f7278e123757987570c72f1216acc2.tar.xz
glibc-7b3551e3a8f7278e123757987570c72f1216acc2.zip
Make strtok benchmark competive.
We include a generic version of strtok to result which could be faster
when underlying primitives are better optimized than current version.
Diffstat (limited to 'benchtests/bench-strtok.c')
-rw-r--r--benchtests/bench-strtok.c61
1 files changed, 4 insertions, 57 deletions
diff --git a/benchtests/bench-strtok.c b/benchtests/bench-strtok.c
index 5e80c1a775..f2f3f575cd 100644
--- a/benchtests/bench-strtok.c
+++ b/benchtests/bench-strtok.c
@@ -20,66 +20,13 @@
 #define TEST_NAME "strtok"
 #include "bench-string.h"
 
-char *
-simple_strtok (char *s1, char *s2)
-{
-  static char *saveptr;
-  char *token;
-  ssize_t i = 0, j = 0;
-  int found = 0;
-  size_t s2len = strlen (s2);
-
-  if (s1 == NULL)
-    s1 = saveptr;
-  if (s1 == NULL || *s1 == '\0')
-    return NULL;
-
-  while (!found)
-    {
-      if (s1[i] == '\0')
-	{
-	  saveptr = NULL;
-	  return NULL;
-	}
-      for (j = 0; j < s2len; j++)
-	{
-	  if (s1[i] == s2[j])
-	    {
-	      i++;
-	      found = 0;
-	      break;
-	    }
-	  found = 1;
-	}
-    }
-  token = s1 + i;
-  i++;
-  found = 0;
-  while (!found)
-    {
-      if (s1[i] == '\0')
-	{
-	  saveptr = NULL;
-	  return token;
-	}
-      for (j = 0; j < s2len; j++)
-	{
-	  if (s1[i] == s2[j])
-	    {
-	      found = 1;
-	      break;
-	    }
-	}
-      i++;
-    }
-  s1[i - 1] = '\0';
-  saveptr = s1 + i;
-  return token;
-}
+#define STRTOK strtok_string
+#include <string/strtok.c>
+
 
 typedef char *(*proto_t) (const char *, const char *);
 
-IMPL (simple_strtok, 0)
+IMPL (strtok_string, 0)
 IMPL (strtok, 1)
 
 static void