diff options
author | Wilco Dijkstra <wdijkstr@arm.com> | 2019-04-09 11:54:34 +0100 |
---|---|---|
committer | Wilco Dijkstra <wdijkstr@arm.com> | 2019-04-09 11:54:34 +0100 |
commit | 648279f4af423c4783ec1dfa63cb7b46a7640217 (patch) | |
tree | fb9277130379baddc55546b600f2c1b0d4b947ad /benchtests/bench-strncat.c | |
parent | 93eebae5168e5cf2abfb4b6266e3fb2ab860cd60 (diff) | |
download | glibc-648279f4af423c4783ec1dfa63cb7b46a7640217.tar.gz glibc-648279f4af423c4783ec1dfa63cb7b46a7640217.tar.xz glibc-648279f4af423c4783ec1dfa63cb7b46a7640217.zip |
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.
Diffstat (limited to 'benchtests/bench-strncat.c')
-rw-r--r-- | benchtests/bench-strncat.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/benchtests/bench-strncat.c b/benchtests/bench-strncat.c index 386eafa429..7271626d50 100644 --- a/benchtests/bench-strncat.c +++ b/benchtests/bench-strncat.c @@ -21,41 +21,33 @@ # define TEST_NAME "strncat" #else # define TEST_NAME "wcsncat" +# define generic_strncat generic_wcsncat #endif /* WIDE */ #include "bench-string.h" #define BIG_CHAR MAX_CHAR #ifndef WIDE -# define SIMPLE_STRNCAT simple_strncat -# define STUPID_STRNCAT stupid_strncat # define SMALL_CHAR 127 #else -# define SIMPLE_STRNCAT simple_wcsncat -# define STUPID_STRNCAT stupid_wcsncat # define SMALL_CHAR 1273 #endif /* WIDE */ typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t); -CHAR *STUPID_STRNCAT (CHAR *, const CHAR *, size_t); -CHAR *SIMPLE_STRNCAT (CHAR *, const CHAR *, size_t); - -IMPL (STUPID_STRNCAT, 0) -IMPL (STRNCAT, 2) CHAR * -STUPID_STRNCAT (CHAR *dst, const CHAR *src, size_t n) +generic_strncat (CHAR *dst, const CHAR *src, size_t n) { - CHAR *ret = dst; - while (*dst++ != '\0'); - --dst; - while (n--) - if ((*dst++ = *src++) == '\0') - return ret; - *dst = '\0'; - return ret; + CHAR *end = dst + STRLEN (dst); + n = STRNLEN (src, n); + end[n] = 0; + MEMCPY (end, src, n); + return dst; } +IMPL (STRNCAT, 2) +IMPL (generic_strncat, 0) + static void do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t n) { |