From 648279f4af423c4783ec1dfa63cb7b46a7640217 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Tue, 9 Apr 2019 11:54:34 +0100 Subject: Improve string benchtests Replace slow byte-oriented tests in several string benchmarks with the generic implementations from the string/ directory so the comparisons are more realistic and useful. * benchtests/bench-stpcpy.c (SIMPLE_STPCPY): Remove function. (generic_stpcpy): New function. * benchtests/bench-stpncpy.c (SIMPLE_STPNCPY): Remove function. (generic_stpncpy): New function. * benchtests/bench-strcat.c (SIMPLE_STRCAT): Remove function. (generic_strcat): New function. * benchtests/bench-strcpy.c (SIMPLE_STRCPY): Remove function. (generic_strcpy): New function. * benchtests/bench-strncat.c (SIMPLE_STRNCAT): Remove function. (STUPID_STRNCAT): Remove function. (generic_strncat): New function. * benchtests/bench-strncpy.c (SIMPLE_STRNCPY): Remove function. (STUPID_STRNCPY): Remove function. (generic_strncpy): New function. * benchtests/bench-strnlen.c (SIMPLE_STRNLEN): Remove function. (generic_strnlen): New function. (memchr_strnlen): New function. * benchtests/bench-strlen.c (generic_strlen): Define for WIDE. (memchr_strlen): Likewise. --- benchtests/bench-strcat.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'benchtests/bench-strcat.c') diff --git a/benchtests/bench-strcat.c b/benchtests/bench-strcat.c index a21d94a28e..39d9fefb09 100644 --- a/benchtests/bench-strcat.c +++ b/benchtests/bench-strcat.c @@ -21,6 +21,7 @@ # define TEST_NAME "strcat" #else # define TEST_NAME "wcscat" +# define generic_strcat generic_wcscat #endif /* WIDE */ #include "bench-string.h" @@ -28,31 +29,25 @@ #ifndef WIDE # define sfmt "s" -# define SIMPLE_STRCAT simple_strcat # define SMALL_CHAR 127 #else # define sfmt "ls" -# define SIMPLE_STRCAT simple_wcscat # define SMALL_CHAR 1273 #endif /* WIDE */ typedef CHAR *(*proto_t) (CHAR *, const CHAR *); -CHAR *SIMPLE_STRCAT (CHAR *, const CHAR *); - -IMPL (SIMPLE_STRCAT, 0) -IMPL (STRCAT, 1) CHAR * -SIMPLE_STRCAT (CHAR *dst, const CHAR *src) +generic_strcat (CHAR *dst, const CHAR *src) { - CHAR *ret = dst; - while (*dst++ != '\0'); - --dst; - while ((*dst++ = *src++) != '\0'); - return ret; + STRCPY (dst + STRLEN (dst), src); + return dst; } +IMPL (STRCAT, 1) +IMPL (generic_strcat, 0) + static void do_one_test (impl_t *impl, CHAR *dst, const CHAR *src) { -- cgit 1.4.1