1 /* Measure bzero functions with large data sizes.
2 Copyright (C) 2022 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/>. */
21 # define TEST_NAME "memset"
23 # define TEST_NAME "bzero"
25 #define START_SIZE (128 * 1024)
26 #define MIN_PAGE_SIZE (getpagesize () + 64 * 1024 * 1024)
27 #define TIMEOUT (20 * 60)
28 #include "bench-string.h"
33 void *generic_memset (void *, int, size_t);
35 typedef void *(*proto_t
) (void *, int, size_t);
38 IMPL (generic_memset
, 0)
41 memset_zero (void * s
, size_t len
)
43 memset (s
, '\0', len
);
46 typedef void (*proto_t
) (void *, size_t);
53 do_one_test (json_ctx_t
*json_ctx
, impl_t
*impl
, CHAR
*s
, size_t n
)
56 timing_t start
, stop
, cur
;
59 for (i
= 0; i
< iters
; ++i
)
69 TIMING_DIFF (cur
, start
, stop
);
71 json_element_double (json_ctx
, (double) cur
/ (double) iters
);
75 do_test (json_ctx_t
*json_ctx
, size_t align
, size_t len
)
78 if ((align
+ len
) * sizeof (CHAR
) > page_size
)
81 json_element_object_begin (json_ctx
);
82 json_attr_uint (json_ctx
, "length", len
);
83 json_attr_uint (json_ctx
, "alignment", align
);
84 json_array_begin (json_ctx
, "timings");
86 FOR_EACH_IMPL (impl
, 0)
88 do_one_test (json_ctx
, impl
, (CHAR
*) (buf1
) + align
, len
);
92 json_array_end (json_ctx
);
93 json_element_object_end (json_ctx
);
104 json_init (&json_ctx
, 0, stdout
);
106 json_document_begin (&json_ctx
);
107 json_attr_string (&json_ctx
, "timing_type", TIMING_TYPE
);
109 json_attr_object_begin (&json_ctx
, "functions");
110 json_attr_object_begin (&json_ctx
, TEST_NAME
);
111 json_attr_string (&json_ctx
, "bench-variant", "large");
113 json_array_begin (&json_ctx
, "ifuncs");
114 FOR_EACH_IMPL (impl
, 0)
115 json_element_string (&json_ctx
, impl
->name
);
116 json_array_end (&json_ctx
);
118 json_array_begin (&json_ctx
, "results");
120 for (i
= START_SIZE
; i
<= MIN_PAGE_SIZE
; i
<<= 1)
122 do_test (&json_ctx
, 0, i
);
123 do_test (&json_ctx
, 3, i
);
126 json_array_end (&json_ctx
);
127 json_attr_object_end (&json_ctx
);
128 json_attr_object_end (&json_ctx
);
129 json_document_end (&json_ctx
);
134 #include <support/test-driver.c>
137 # define libc_hidden_builtin_def(X)
138 # define libc_hidden_def(X)
139 # define libc_hidden_weak(X)
140 # define weak_alias(X,Y)
142 # define MEMSET generic_memset
143 # include <string/memset.c>