1 /* Measure memset functions with large data sizes.
2 Copyright (C) 2016-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 #define TEST_NAME "memset"
21 #define START_SIZE (128 * 1024)
22 #define MIN_PAGE_SIZE (getpagesize () + 64 * 1024 * 1024)
23 #define TIMEOUT (20 * 60)
24 #include "bench-string.h"
29 void *generic_memset (void *, int, size_t);
30 typedef void *(*proto_t
) (void *, int, size_t);
33 IMPL (generic_memset
, 0)
36 do_one_test (json_ctx_t
*json_ctx
, impl_t
*impl
, CHAR
*s
,
37 int c
__attribute ((unused
)), size_t n
)
40 timing_t start
, stop
, cur
;
43 for (i
= 0; i
< iters
; ++i
)
49 TIMING_DIFF (cur
, start
, stop
);
51 json_element_double (json_ctx
, (double) cur
/ (double) iters
);
55 do_test (json_ctx_t
*json_ctx
, size_t align
, int c
, size_t len
)
58 if ((align
+ len
) * sizeof (CHAR
) > page_size
)
61 json_element_object_begin (json_ctx
);
62 json_attr_uint (json_ctx
, "length", len
);
63 json_attr_uint (json_ctx
, "alignment", align
);
64 json_attr_int (json_ctx
, "char", c
);
65 json_array_begin (json_ctx
, "timings");
67 FOR_EACH_IMPL (impl
, 0)
69 do_one_test (json_ctx
, impl
, (CHAR
*) (buf1
) + align
, c
, len
);
73 json_array_end (json_ctx
);
74 json_element_object_end (json_ctx
);
86 json_init (&json_ctx
, 0, stdout
);
88 json_document_begin (&json_ctx
);
89 json_attr_string (&json_ctx
, "timing_type", TIMING_TYPE
);
91 json_attr_object_begin (&json_ctx
, "functions");
92 json_attr_object_begin (&json_ctx
, TEST_NAME
);
93 json_attr_string (&json_ctx
, "bench-variant", "large");
95 json_array_begin (&json_ctx
, "ifuncs");
96 FOR_EACH_IMPL (impl
, 0)
97 json_element_string (&json_ctx
, impl
->name
);
98 json_array_end (&json_ctx
);
100 json_array_begin (&json_ctx
, "results");
103 for (i
= START_SIZE
; i
<= MIN_PAGE_SIZE
; i
<<= 1)
105 do_test (&json_ctx
, 0, c
, i
);
106 do_test (&json_ctx
, 3, c
, i
);
109 json_array_end (&json_ctx
);
110 json_attr_object_end (&json_ctx
);
111 json_attr_object_end (&json_ctx
);
112 json_document_end (&json_ctx
);
117 #include <support/test-driver.c>
119 #define libc_hidden_builtin_def(X)
120 #define libc_hidden_def(X)
121 #define libc_hidden_weak(X)
122 #define weak_alias(X,Y)
124 #define MEMSET generic_memset
125 #include <string/memset.c>