2013-06-04 11:18:56 +00:00
|
|
|
/* Measure memset functions.
|
2019-01-01 00:11:28 +00:00
|
|
|
Copyright (C) 2013-2019 Free Software Foundation, Inc.
|
2013-06-04 11:18:56 +00:00
|
|
|
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
|
2015-08-26 08:26:25 +00:00
|
|
|
#ifndef WIDE
|
2019-02-12 17:19:51 +00:00
|
|
|
# define TEST_NAME "memset"
|
2015-08-26 08:26:25 +00:00
|
|
|
#else
|
2019-02-12 17:19:51 +00:00
|
|
|
# define TEST_NAME "wmemset"
|
2015-08-26 08:26:25 +00:00
|
|
|
#endif /* WIDE */
|
2019-02-12 17:19:51 +00:00
|
|
|
#define MIN_PAGE_SIZE 131072
|
|
|
|
#include "bench-string.h"
|
2015-08-26 08:26:25 +00:00
|
|
|
|
2017-09-14 17:07:33 +00:00
|
|
|
#include "json-lib.h"
|
|
|
|
|
2015-08-26 08:26:25 +00:00
|
|
|
CHAR *SIMPLE_MEMSET (CHAR *, int, size_t);
|
2013-06-04 11:18:56 +00:00
|
|
|
|
2015-08-26 08:26:25 +00:00
|
|
|
typedef CHAR *(*proto_t) (CHAR *, int, size_t);
|
2013-06-04 11:18:56 +00:00
|
|
|
|
2015-08-26 08:26:25 +00:00
|
|
|
IMPL (MEMSET, 1)
|
2019-02-12 17:19:51 +00:00
|
|
|
IMPL (SIMPLE_MEMSET, 0)
|
2013-06-04 11:18:56 +00:00
|
|
|
|
2015-08-26 08:26:25 +00:00
|
|
|
CHAR *
|
2013-06-21 00:40:55 +00:00
|
|
|
inhibit_loop_to_libcall
|
2015-08-26 08:26:25 +00:00
|
|
|
SIMPLE_MEMSET (CHAR *s, int c, size_t n)
|
2013-06-04 11:18:56 +00:00
|
|
|
{
|
2015-08-26 08:26:25 +00:00
|
|
|
CHAR *r = s, *end = s + n;
|
2013-06-04 11:18:56 +00:00
|
|
|
while (r < end)
|
|
|
|
*r++ = c;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-09-14 17:07:33 +00:00
|
|
|
do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s,
|
|
|
|
int c __attribute ((unused)), size_t n)
|
2013-06-04 11:18:56 +00:00
|
|
|
{
|
2013-09-02 13:13:50 +00:00
|
|
|
size_t i, iters = INNER_LOOP_ITERS;
|
|
|
|
timing_t start, stop, cur;
|
2013-06-04 11:18:56 +00:00
|
|
|
|
2013-09-02 13:13:50 +00:00
|
|
|
TIMING_NOW (start);
|
|
|
|
for (i = 0; i < iters; ++i)
|
2013-06-04 11:18:56 +00:00
|
|
|
{
|
2013-09-02 13:13:50 +00:00
|
|
|
CALL (impl, s, c, n);
|
|
|
|
}
|
|
|
|
TIMING_NOW (stop);
|
2013-06-04 11:18:56 +00:00
|
|
|
|
2013-09-02 13:13:50 +00:00
|
|
|
TIMING_DIFF (cur, start, stop);
|
2013-06-04 11:18:56 +00:00
|
|
|
|
2017-09-14 17:07:33 +00:00
|
|
|
json_element_double (json_ctx, (double) cur / (double) iters);
|
2013-06-04 11:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-09-14 17:07:33 +00:00
|
|
|
do_test (json_ctx_t *json_ctx, size_t align, int c, size_t len)
|
2013-06-04 11:18:56 +00:00
|
|
|
{
|
2016-04-01 17:00:01 +00:00
|
|
|
align &= 63;
|
2015-08-26 08:26:25 +00:00
|
|
|
if ((align + len) * sizeof (CHAR) > page_size)
|
2013-06-04 11:18:56 +00:00
|
|
|
return;
|
|
|
|
|
2017-09-14 17:07:33 +00:00
|
|
|
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");
|
2013-06-04 11:18:56 +00:00
|
|
|
|
|
|
|
FOR_EACH_IMPL (impl, 0)
|
2017-09-14 17:09:49 +00:00
|
|
|
{
|
|
|
|
do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, c, len);
|
2018-08-07 19:14:56 +00:00
|
|
|
alloc_bufs ();
|
2017-09-14 17:09:49 +00:00
|
|
|
}
|
2013-06-04 11:18:56 +00:00
|
|
|
|
2017-09-14 17:07:33 +00:00
|
|
|
json_array_end (json_ctx);
|
|
|
|
json_element_object_end (json_ctx);
|
2013-06-04 11:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
test_main (void)
|
|
|
|
{
|
2017-09-14 17:07:33 +00:00
|
|
|
json_ctx_t json_ctx;
|
2013-06-04 11:18:56 +00:00
|
|
|
size_t i;
|
|
|
|
int c = 0;
|
|
|
|
|
|
|
|
test_init ();
|
|
|
|
|
2017-09-14 17:07:33 +00:00
|
|
|
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");
|
2013-06-04 11:18:56 +00:00
|
|
|
FOR_EACH_IMPL (impl, 0)
|
2017-09-14 17:07:33 +00:00
|
|
|
json_element_string (&json_ctx, impl->name);
|
|
|
|
json_array_end (&json_ctx);
|
|
|
|
|
|
|
|
json_array_begin (&json_ctx, "results");
|
2013-06-04 11:18:56 +00:00
|
|
|
|
|
|
|
for (c = -65; c <= 130; c += 65)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 18; ++i)
|
2017-09-14 17:07:33 +00:00
|
|
|
do_test (&json_ctx, 0, c, 1 << i);
|
2013-06-04 11:18:56 +00:00
|
|
|
for (i = 1; i < 32; ++i)
|
|
|
|
{
|
2017-09-14 17:07:33 +00:00
|
|
|
do_test (&json_ctx, i, c, i);
|
2013-06-04 11:18:56 +00:00
|
|
|
if (i & (i - 1))
|
2017-09-14 17:07:33 +00:00
|
|
|
do_test (&json_ctx, 0, c, i);
|
2013-06-04 11:18:56 +00:00
|
|
|
}
|
2014-07-15 16:19:09 +00:00
|
|
|
for (i = 32; i < 512; i+=32)
|
|
|
|
{
|
2017-09-14 17:07:33 +00:00
|
|
|
do_test (&json_ctx, 0, c, i);
|
|
|
|
do_test (&json_ctx, i, c, i);
|
2014-07-15 16:19:09 +00:00
|
|
|
}
|
2017-09-14 17:07:33 +00:00
|
|
|
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);
|
2013-06-04 11:18:56 +00:00
|
|
|
}
|
2016-04-01 17:00:01 +00:00
|
|
|
for (i = 33; i <= 256; i += 4)
|
|
|
|
{
|
2017-09-14 17:07:33 +00:00
|
|
|
do_test (&json_ctx, 0, c, 32 * i);
|
|
|
|
do_test (&json_ctx, i, c, 32 * i);
|
2016-04-01 17:00:01 +00:00
|
|
|
}
|
2013-06-04 11:18:56 +00:00
|
|
|
|
2017-09-14 17:07:33 +00:00
|
|
|
json_array_end (&json_ctx);
|
|
|
|
json_attr_object_end (&json_ctx);
|
|
|
|
json_attr_object_end (&json_ctx);
|
|
|
|
json_document_end (&json_ctx);
|
|
|
|
|
2013-06-04 11:18:56 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-12-16 17:35:06 +00:00
|
|
|
#include <support/test-driver.c>
|