]> git.ipfire.org Git - thirdparty/glibc.git/blame - benchtests/bench-bzero-large.c
i686: Remove bzero optimizations
[thirdparty/glibc.git] / benchtests / bench-bzero-large.c
CommitLineData
dc98eeeb
L
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.
4
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.
9
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.
14
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/>. */
18
19#define TEST_MAIN
20#define TEST_NAME "bzero"
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"
25
26#include "json-lib.h"
27
28static void
29memset_zero (void * s, size_t len)
30{
31 memset (s, '\0', len);
32}
33
34typedef void (*proto_t) (void *, size_t);
35
36IMPL (bzero, 1)
37IMPL (memset_zero, 0)
38
39static void
40do_one_test (json_ctx_t *json_ctx, impl_t *impl, CHAR *s, size_t n)
41{
42 size_t i, iters = 16;
43 timing_t start, stop, cur;
44
45 TIMING_NOW (start);
46 for (i = 0; i < iters; ++i)
47 {
48 CALL (impl, s, n);
49 }
50 TIMING_NOW (stop);
51
52 TIMING_DIFF (cur, start, stop);
53
54 json_element_double (json_ctx, (double) cur / (double) iters);
55}
56
57static void
58do_test (json_ctx_t *json_ctx, size_t align, size_t len)
59{
60 align &= 63;
61 if ((align + len) * sizeof (CHAR) > page_size)
62 return;
63
64 json_element_object_begin (json_ctx);
65 json_attr_uint (json_ctx, "length", len);
66 json_attr_uint (json_ctx, "alignment", align);
67 json_array_begin (json_ctx, "timings");
68
69 FOR_EACH_IMPL (impl, 0)
70 {
71 do_one_test (json_ctx, impl, (CHAR *) (buf1) + align, len);
72 alloc_bufs ();
73 }
74
75 json_array_end (json_ctx);
76 json_element_object_end (json_ctx);
77}
78
79int
80test_main (void)
81{
82 json_ctx_t json_ctx;
83 size_t i;
84
85 test_init ();
86
87 json_init (&json_ctx, 0, stdout);
88
89 json_document_begin (&json_ctx);
90 json_attr_string (&json_ctx, "timing_type", TIMING_TYPE);
91
92 json_attr_object_begin (&json_ctx, "functions");
93 json_attr_object_begin (&json_ctx, TEST_NAME);
94 json_attr_string (&json_ctx, "bench-variant", "large");
95
96 json_array_begin (&json_ctx, "ifuncs");
97 FOR_EACH_IMPL (impl, 0)
98 json_element_string (&json_ctx, impl->name);
99 json_array_end (&json_ctx);
100
101 json_array_begin (&json_ctx, "results");
102
103 for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
104 {
105 do_test (&json_ctx, 0, i);
106 do_test (&json_ctx, 3, i);
107 }
108
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);
113
114 return ret;
115}
116
117#include <support/test-driver.c>