mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-29 00:01:12 +00:00
16f87cfd63
Continue cleanup of the string benchtests. Remove simplistic byte-oriented versions with faster generic implementations. Remove bcopy/bzero benchmarks (bcopy/bzero are obsolete and never emitted by compilers). Remove builtin versions of memcpy, memset and strlen. Remove all remaining "stupid" implementations given they are always slower than the "simple" variants and thus don't add anything useful. * benchtests/bench-strcasecmp.c (stupid_strcasecmp): Remove. * benchtests/bench-strcasestr.c (stupid_strcasestr): Remove. * benchtests/bench-strchr.c (stupid_strchr): Remove. * benchtests/bench-strcmp.c (stupid_strcmp): Remove. * benchtests/bench-strcspn.c (stupid_strcspn): Remove. * benchtests/bench-strlen.c (builtin_strlen): Remove. * benchtests/bench-strncasecmp.c (stupid_strncasecmp): Remove. * benchtests/bench-strncmp.c (stupid_strncmp): Remove. * benchtests/bench-strpbrk.c (stupid_strpbrk): Remove. * benchtests/bench-strspn.c (stupid_strspn): Remove. * benchtests/Makefile: Remove bench-bcopy.c and bench-bzero.c. * benchtests/bench-bcopy.c: Delete file. * benchtests/bench-bzero.c: Likewise. * benchtests/bench-memccpy.c (stupid_memccpy): Remove. (simple_memccpy): Remove. (generic_memccpy): Add function. * benchtests/bench-memcpy.c: (builtin_memcpy): Remove. * benchtests/bench-memmove.c (simple_bcopy): Remove. * benchtests/bench-mempcpy.c (simple_mempcpy): Remove. (generic_mempcpy): Add new function. * benchtests/bench-memset.c (simple_bzero): Remove. (builtin_bzero): Remove. (builtin_memset): Remove. * benchtests/bench-rawmemchr.c (simple_rawmemchr): Remove. (generic_rawmemchr): Add new function.
149 lines
3.6 KiB
C
149 lines
3.6 KiB
C
/* Measure memset functions.
|
|
Copyright (C) 2013-2019 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_MAIN
|
|
#ifndef WIDE
|
|
# define TEST_NAME "memset"
|
|
#else
|
|
# 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);
|
|
|
|
typedef CHAR *(*proto_t) (CHAR *, int, size_t);
|
|
|
|
IMPL (MEMSET, 1)
|
|
IMPL (SIMPLE_MEMSET, 0)
|
|
|
|
CHAR *
|
|
inhibit_loop_to_libcall
|
|
SIMPLE_MEMSET (CHAR *s, int c, size_t n)
|
|
{
|
|
CHAR *r = s, *end = s + n;
|
|
while (r < end)
|
|
*r++ = c;
|
|
return s;
|
|
}
|
|
|
|
static void
|
|
do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s,
|
|
int c __attribute ((unused)), size_t n)
|
|
{
|
|
size_t i, iters = INNER_LOOP_ITERS;
|
|
timing_t start, stop, cur;
|
|
|
|
TIMING_NOW (start);
|
|
for (i = 0; i < iters; ++i)
|
|
{
|
|
CALL (impl, s, c, n);
|
|
}
|
|
TIMING_NOW (stop);
|
|
|
|
TIMING_DIFF (cur, start, stop);
|
|
|
|
json_element_double (json_ctx, (double) cur / (double) iters);
|
|
}
|
|
|
|
static void
|
|
do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len)
|
|
{
|
|
align &= 63;
|
|
if ((align + len) * sizeof (CHAR) > page_size)
|
|
return;
|
|
|
|
json_element_object_begin (json_ctx);
|
|
json_attr_uint (json_ctx, "length", len);
|
|
json_attr_uint (json_ctx, "alignment", align);
|
|
json_attr_int (json_ctx, "char", c);
|
|
json_array_begin (json_ctx, "timings");
|
|
|
|
FOR_EACH_IMPL (impl, 0)
|
|
{
|
|
do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, c, len);
|
|
alloc_bufs ();
|
|
}
|
|
|
|
json_array_end (json_ctx);
|
|
json_element_object_end (json_ctx);
|
|
}
|
|
|
|
int
|
|
test_main (void)
|
|
{
|
|
json_ctx_t json_ctx;
|
|
size_t i;
|
|
int c = 0;
|
|
|
|
test_init ();
|
|
|
|
json_init (&json_ctx, 0, stdout);
|
|
|
|
json_document_begin (&json_ctx);
|
|
json_attr_string (&json_ctx, "timing_type", TIMING_TYPE);
|
|
|
|
json_attr_object_begin (&json_ctx, "functions");
|
|
json_attr_object_begin (&json_ctx, TEST_NAME);
|
|
json_attr_string (&json_ctx, "bench-variant", "");
|
|
|
|
json_array_begin (&json_ctx, "ifuncs");
|
|
FOR_EACH_IMPL (impl, 0)
|
|
json_element_string (&json_ctx, impl->name);
|
|
json_array_end (&json_ctx);
|
|
|
|
json_array_begin (&json_ctx, "results");
|
|
|
|
for (c = -65; c <= 130; c += 65)
|
|
{
|
|
for (i = 0; i < 18; ++i)
|
|
do_test (&json_ctx, 0, c, 1 << i);
|
|
for (i = 1; i < 32; ++i)
|
|
{
|
|
do_test (&json_ctx, i, c, i);
|
|
if (i & (i - 1))
|
|
do_test (&json_ctx, 0, c, i);
|
|
}
|
|
for (i = 32; i < 512; i+=32)
|
|
{
|
|
do_test (&json_ctx, 0, c, i);
|
|
do_test (&json_ctx, i, c, i);
|
|
}
|
|
do_test (&json_ctx, 1, c, 14);
|
|
do_test (&json_ctx, 3, c, 1024);
|
|
do_test (&json_ctx, 4, c, 64);
|
|
do_test (&json_ctx, 2, c, 25);
|
|
}
|
|
for (i = 33; i <= 256; i += 4)
|
|
{
|
|
do_test (&json_ctx, 0, c, 32 * i);
|
|
do_test (&json_ctx, i, c, 32 * i);
|
|
}
|
|
|
|
json_array_end (&json_ctx);
|
|
json_attr_object_end (&json_ctx);
|
|
json_attr_object_end (&json_ctx);
|
|
json_document_end (&json_ctx);
|
|
|
|
return ret;
|
|
}
|
|
|
|
#include <support/test-driver.c>
|