diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-02-09 07:31:41 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-02-23 12:07:06 -0800 |
commit | cf975913131169a753acf0621e08e72bc40a91e2 (patch) | |
tree | c6bd75c58e59b32546e5744e29e086feb7072bee /benchtests/bench-bzero.c | |
parent | 0f88a5c66e1cbb574bf37d953bf7155c0a1f5ae7 (diff) | |
download | glibc-cf975913131169a753acf0621e08e72bc40a91e2.zip glibc-cf975913131169a753acf0621e08e72bc40a91e2.tar.gz glibc-cf975913131169a753acf0621e08e72bc40a91e2.tar.bz2 |
benchtests: Add benches for memset with 0 value
memset with zero as the value to set is by far the majority value (99%+
for Python3 and GCC). Add bench-memset-zero-large.c,
bench-memset-zero-walk.c and bench-memset-zero.c to measure memset
implementations for zeroing.
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
Diffstat (limited to 'benchtests/bench-bzero.c')
-rw-r--r-- | benchtests/bench-bzero.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/benchtests/bench-bzero.c b/benchtests/bench-bzero.c index 93ec521..500b7eb 100644 --- a/benchtests/bench-bzero.c +++ b/benchtests/bench-bzero.c @@ -17,12 +17,25 @@ <https://www.gnu.org/licenses/>. */ #define TEST_MAIN -#define TEST_NAME "bzero" +#ifdef DO_MEMSET +# define TEST_NAME "memset" +#else +# define TEST_NAME "bzero" +#endif #define MIN_PAGE_SIZE 131072 #include "bench-string.h" #include "json-lib.h" +#ifdef DO_MEMSET +void *generic_memset (void *, int, size_t); + +typedef void *(*proto_t) (void *, int, size_t); + +IMPL (memset, 1) +IMPL (generic_memset, 0) + +#else static void memset_zero (void * s, size_t len) { @@ -33,6 +46,7 @@ typedef void (*proto_t) (void *, size_t); IMPL (bzero, 1) IMPL (memset_zero, 0) +#endif static void do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, size_t n) @@ -43,7 +57,11 @@ do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, size_t n) TIMING_NOW (start); for (i = 0; i < iters; ++i) { +#ifdef DO_MEMSET + CALL (impl, s, 0, n); +#else CALL (impl, s, n); +#endif } TIMING_NOW (stop); @@ -132,3 +150,13 @@ test_main (void) } #include <support/test-driver.c> + +#ifdef DO_MEMSET +# define libc_hidden_builtin_def(X) +# define libc_hidden_def(X) +# define libc_hidden_weak(X) +# define weak_alias(X,Y) +# undef MEMSET +# define MEMSET generic_memset +# include <string/memset.c> +#endif |