@@ -37,7 +37,7 @@ bench := $(foreach B,$(filter bench-%,${BENCHSET}), ${${B}})
endif
# String function benchmarks.
-string-benchset := bcopy bzero memccpy memchr memcmp memcpy memmem memmove \
+string-benchset := memccpy memchr memcmp memcpy memmem memmove \
mempcpy memset rawmemchr stpcpy stpncpy strcasecmp strcasestr \
strcat strchr strchrnul strcmp strcpy strcspn strlen \
strncasecmp strncat strncmp strncpy strnlen strpbrk strrchr \
deleted file mode 100644
@@ -1,20 +0,0 @@
-/* Measure bcopy functions.
- 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-
-#define TEST_BCOPY
-#include "bench-memmove.c"
deleted file mode 100644
@@ -1,19 +0,0 @@
-/* Measure bzero functions.
- 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- 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/>. */
-#define TEST_BZERO
-#include "bench-memset.c"
@@ -20,28 +20,8 @@
#define TEST_NAME "memccpy"
#include "bench-string.h"
-void *simple_memccpy (void *, const void *, int, size_t);
-void *stupid_memccpy (void *, const void *, int, size_t);
-
-IMPL (stupid_memccpy, 0)
-IMPL (simple_memccpy, 0)
-IMPL (memccpy, 1)
-
-void *
-simple_memccpy (void *dst, const void *src, int c, size_t n)
-{
- const char *s = src;
- char *d = dst;
-
- while (n-- > 0)
- if ((*d++ = *s++) == (char) c)
- return d;
-
- return NULL;
-}
-
void *
-stupid_memccpy (void *dst, const void *src, int c, size_t n)
+generic_memccpy (void *dst, const void *src, int c, size_t n)
{
void *p = memchr (src, c, n);
@@ -52,6 +32,9 @@ stupid_memccpy (void *dst, const void *src, int c, size_t n)
return NULL;
}
+IMPL (memccpy, 1)
+IMPL (generic_memccpy, 0)
+
typedef void *(*proto_t) (void *, const void *, int c, size_t);
static void
@@ -23,13 +23,6 @@
# define TEST_NAME "memcpy"
# include "bench-string.h"
-char *simple_memcpy (char *, const char *, size_t);
-char *builtin_memcpy (char *, const char *, size_t);
-
-IMPL (simple_memcpy, 0)
-IMPL (builtin_memcpy, 0)
-IMPL (memcpy, 1)
-
char *
simple_memcpy (char *dst, const char *src, size_t n)
{
@@ -44,6 +37,11 @@ builtin_memcpy (char *dst, const char *src, size_t n)
{
return __builtin_memcpy (dst, src, n);
}
+
+IMPL (memcpy, 1)
+IMPL (builtin_memcpy, 0)
+IMPL (simple_memcpy, 0)
+
#endif
# include "json-lib.h"
@@ -17,34 +17,16 @@
<http://www.gnu.org/licenses/>. */
#define TEST_MAIN
-#ifdef TEST_BCOPY
-# define TEST_NAME "bcopy"
-#else
-# define TEST_NAME "memmove"
-#endif
+#define TEST_NAME "memmove"
#include "bench-string.h"
#include "json-lib.h"
char *simple_memmove (char *, const char *, size_t);
-#ifdef TEST_BCOPY
-typedef void (*proto_t) (const char *, char *, size_t);
-void simple_bcopy (const char *, char *, size_t);
-
-IMPL (simple_bcopy, 0)
-IMPL (bcopy, 1)
-
-void
-simple_bcopy (const char *src, char *dst, size_t n)
-{
- simple_memmove (dst, src, n);
-}
-#else
typedef char *(*proto_t) (char *, const char *, size_t);
-IMPL (simple_memmove, 0)
IMPL (memmove, 1)
-#endif
+IMPL (simple_memmove, 0)
char *
inhibit_loop_to_libcall
@@ -74,11 +56,7 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src, const
TIMING_NOW (start);
for (i = 0; i < iters; ++i)
{
-#ifdef TEST_BCOPY
- CALL (impl, src, dst, len);
-#else
CALL (impl, dst, src, len);
-#endif
}
TIMING_NOW (stop);
@@ -21,17 +21,13 @@
#define TEST_NAME "mempcpy"
#include "bench-string.h"
-char *simple_mempcpy (char *, const char *, size_t);
-
-IMPL (simple_mempcpy, 0)
-IMPL (mempcpy, 1)
-
char *
-simple_mempcpy (char *dst, const char *src, size_t n)
+generic_mempcpy (char *dst, const char *src, size_t n)
{
- while (n--)
- *dst++ = *src++;
- return dst;
+ return memcpy (dst, src, n) + n;
}
+IMPL (mempcpy, 1)
+IMPL (generic_mempcpy, 0)
+
#include "bench-memcpy.c"
@@ -17,66 +17,32 @@
<http://www.gnu.org/licenses/>. */
#define TEST_MAIN
-#ifdef TEST_BZERO
-# define TEST_NAME "bzero"
-#else
-# ifndef WIDE
-# define TEST_NAME "memset"
-# else
-# define TEST_NAME "wmemset"
-# endif /* WIDE */
-#endif /* !TEST_BZERO */
-#define MIN_PAGE_SIZE 131072
-#include "bench-string.h"
-
#ifndef WIDE
-# define SIMPLE_MEMSET simple_memset
+# define TEST_NAME "memset"
#else
-# define SIMPLE_MEMSET simple_wmemset
+# define TEST_NAME "wmemset"
#endif /* WIDE */
+#define MIN_PAGE_SIZE 131072
+#include "bench-string.h"
#include "json-lib.h"
CHAR *SIMPLE_MEMSET (CHAR *, int, size_t);
-#ifdef TEST_BZERO
-typedef void (*proto_t) (char *, size_t);
-void simple_bzero (char *, size_t);
-void builtin_bzero (char *, size_t);
-
-IMPL (simple_bzero, 0)
-IMPL (builtin_bzero, 0)
-IMPL (bzero, 1)
-
-void
-simple_bzero (char *s, size_t n)
-{
- SIMPLE_MEMSET (s, 0, n);
-}
-
-void
-builtin_bzero (char *s, size_t n)
-{
- __builtin_bzero (s, n);
-}
-#else
typedef CHAR *(*proto_t) (CHAR *, int, size_t);
-IMPL (SIMPLE_MEMSET, 0)
-# ifndef WIDE
-char *builtin_memset (char *, int, size_t);
-IMPL (builtin_memset, 0)
-# endif /* !WIDE */
IMPL (MEMSET, 1)
+IMPL (SIMPLE_MEMSET, 0)
-# ifndef WIDE
+#ifndef WIDE
char *
builtin_memset (char *s, int c, size_t n)
{
return __builtin_memset (s, c, n);
}
-# endif /* !WIDE */
-#endif /* !TEST_BZERO */
+
+IMPL (builtin_memset, 0)
+#endif /* !WIDE */
CHAR *
inhibit_loop_to_libcall
@@ -95,14 +61,12 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s,
size_t i, iters = INNER_LOOP_ITERS;
timing_t start, stop, cur;
+ memset (s, 0, n);
+
TIMING_NOW (start);
for (i = 0; i < iters; ++i)
{
-#ifdef TEST_BZERO
- CALL (impl, s, n);
-#else
CALL (impl, s, c, n);
-#endif /* !TEST_BZERO */
}
TIMING_NOW (stop);
@@ -159,9 +123,7 @@ test_main (void)
json_array_begin (&json_ctx, "results");
-#ifndef TEST_BZERO
for (c = -65; c <= 130; c += 65)
-#endif
{
for (i = 0; i < 18; ++i)
do_test (&json_ctx, 0, c, 1 << i);
@@ -23,20 +23,18 @@
#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)
{