]> git.ipfire.org Git - thirdparty/glibc.git/blame - benchtests/bench-memmove-large.c
C-SKY: add elf header definition for elfutils
[thirdparty/glibc.git] / benchtests / bench-memmove-large.c
CommitLineData
a25322f4 1/* Measure memmove functions with large data sizes.
04277e02 2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
a25322f4
L
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 BASE_PAGE_SIZE (1024 * 1024)
20#define START_SIZE (4 * 1024)
21#define MIN_PAGE_SIZE (getpagesize () + 16 * 1024 * 1024)
22#define TEST_MAIN
23#define TEST_NAME "memmove"
24#define TIMEOUT (20 * 60)
25#include "bench-string.h"
86c6519e 26#include "json-lib.h"
a25322f4
L
27
28IMPL (memmove, 1)
29
30typedef char *(*proto_t) (char *, const char *, size_t);
31
32static void
24ca04fe
SP
33do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src,
34 size_t len)
a25322f4
L
35{
36 size_t i, iters = 16;
37 timing_t start, stop, cur;
38
a25322f4
L
39 TIMING_NOW (start);
40 for (i = 0; i < iters; ++i)
41 {
42 CALL (impl, dst, src, len);
43 }
44 TIMING_NOW (stop);
45
46 TIMING_DIFF (cur, start, stop);
47
86c6519e 48 json_element_double (json_ctx, (double) cur / (double) iters);
a25322f4
L
49}
50
51static void
86c6519e 52do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
a25322f4
L
53{
54 size_t i, j;
55 char *s1, *s2;
56
57 align1 &= 127;
58 if (align1 + len >= page_size)
59 return;
60
61 align2 &= 127;
62 if (align2 + len >= page_size)
63 return;
64
24ca04fe 65 s1 = (char *) (buf2 + align1);
a25322f4
L
66 s2 = (char *) (buf2 + align2);
67
68 for (i = 0, j = 1; i < len; i++, j += 23)
69 s1[i] = j;
70
86c6519e
SP
71 json_element_object_begin (json_ctx);
72 json_attr_uint (json_ctx, "length", (double) len);
73 json_attr_uint (json_ctx, "align1", (double) align1);
74 json_attr_uint (json_ctx, "align2", (double) align2);
75 json_array_begin (json_ctx, "timings");
a25322f4
L
76
77 FOR_EACH_IMPL (impl, 0)
24ca04fe 78 do_one_test (json_ctx, impl, s2, s1, len);
a25322f4 79
86c6519e
SP
80 json_array_end (json_ctx);
81 json_element_object_end (json_ctx);
a25322f4
L
82}
83
84int
85test_main (void)
86{
86c6519e 87 json_ctx_t json_ctx;
a25322f4
L
88 size_t i;
89
90 test_init ();
91
86c6519e
SP
92 json_init (&json_ctx, 0, stdout);
93
94 json_document_begin (&json_ctx);
95 json_attr_string (&json_ctx, "timing_type", TIMING_TYPE);
96
97 json_attr_object_begin (&json_ctx, "functions");
98 json_attr_object_begin (&json_ctx, "memmove");
99 json_attr_string (&json_ctx, "bench-variant", "large");
100
101 json_array_begin (&json_ctx, "ifuncs");
102
a25322f4 103 FOR_EACH_IMPL (impl, 0)
86c6519e
SP
104 json_element_string (&json_ctx, impl->name);
105 json_array_end (&json_ctx);
a25322f4 106
86c6519e 107 json_array_begin (&json_ctx, "results");
a25322f4
L
108 for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
109 {
86c6519e
SP
110 do_test (&json_ctx, 0, 64, i + 7);
111 do_test (&json_ctx, 0, 3, i + 15);
112 do_test (&json_ctx, 3, 0, i + 31);
113 do_test (&json_ctx, 3, 7, i + 63);
114 do_test (&json_ctx, 9, 5, i + 127);
a25322f4
L
115 }
116
86c6519e
SP
117 json_array_end (&json_ctx);
118 json_attr_object_end (&json_ctx);
119 json_attr_object_end (&json_ctx);
120 json_document_end (&json_ctx);
121
a25322f4
L
122 return ret;
123}
124
b598e134 125#include <support/test-driver.c>