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