]> git.ipfire.org Git - thirdparty/glibc.git/blob - benchtests/bench-memset-large.c
benchtests: Remove verification runs from benchmark tests
[thirdparty/glibc.git] / benchtests / bench-memset-large.c
1 /* Measure memset functions with large data sizes.
2 Copyright (C) 2016-2017 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 <http://www.gnu.org/licenses/>. */
18
19 #define TEST_MAIN
20 #ifndef WIDE
21 # define TEST_NAME "memset"
22 #else
23 # define TEST_NAME "wmemset"
24 #endif /* WIDE */
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"
29
30 #ifndef WIDE
31 # define MEMSET memset
32 # define CHAR char
33 # define SIMPLE_MEMSET simple_memset
34 # define MEMCMP memcmp
35 #else
36 # include <wchar.h>
37 # define MEMSET wmemset
38 # define CHAR wchar_t
39 # define SIMPLE_MEMSET simple_wmemset
40 # define MEMCMP wmemcmp
41 #endif /* WIDE */
42
43 #include <assert.h>
44
45 IMPL (MEMSET, 1)
46
47 typedef CHAR *(*proto_t) (CHAR *, int, size_t);
48
49 CHAR *
50 inhibit_loop_to_libcall
51 SIMPLE_MEMSET (CHAR *s, int c, size_t n)
52 {
53 CHAR *r = s, *end = s + n;
54 while (r < end)
55 *r++ = c;
56 return s;
57 }
58
59 static void
60 do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n)
61 {
62 size_t i, iters = 16;
63 timing_t start, stop, cur;
64
65 TIMING_NOW (start);
66 for (i = 0; i < iters; ++i)
67 {
68 CALL (impl, s, c, n);
69 }
70 TIMING_NOW (stop);
71
72 TIMING_DIFF (cur, start, stop);
73
74 TIMING_PRINT_MEAN ((double) cur, (double) iters);
75 }
76
77 static void
78 do_test (size_t align, int c, size_t len)
79 {
80 align &= 63;
81 if ((align + len) * sizeof (CHAR) > page_size)
82 return;
83
84 printf ("Length %4zd, alignment %2zd, c %2d:", len, align, c);
85
86 FOR_EACH_IMPL (impl, 0)
87 do_one_test (impl, (CHAR *) (buf1) + align, c, len);
88
89 putchar ('\n');
90 }
91
92 int
93 test_main (void)
94 {
95 size_t i;
96 int c;
97
98 test_init ();
99
100 printf ("%24s", "");
101 FOR_EACH_IMPL (impl, 0)
102 printf ("\t%s", impl->name);
103 putchar ('\n');
104
105 c = 65;
106 for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
107 {
108 do_test (0, c, i);
109 do_test (3, c, i);
110 }
111
112 return ret;
113 }
114
115 #include <support/test-driver.c>