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-large.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-large.c')
-rw-r--r-- | benchtests/bench-bzero-large.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/benchtests/bench-bzero-large.c b/benchtests/bench-bzero-large.c index f2e2e98..cfc7b81 100644 --- a/benchtests/bench-bzero-large.c +++ b/benchtests/bench-bzero-large.c @@ -17,7 +17,11 @@ <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 START_SIZE (128 * 1024) #define MIN_PAGE_SIZE (getpagesize () + 64 * 1024 * 1024) #define TIMEOUT (20 * 60) @@ -25,6 +29,14 @@ #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) { @@ -35,6 +47,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) @@ -45,7 +58,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); @@ -115,3 +132,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 |