1 /* Measure memcpy functions with large data sizes.
2 Copyright (C) 2016-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/>. */
20 # define MEMCPY_RESULT(dst, len) dst
21 # define START_SIZE (64 * 1024)
22 # define MIN_PAGE_SIZE (getpagesize () + 32 * 1024 * 1024)
24 # define TEST_NAME "memcpy"
25 # define TIMEOUT (20 * 60)
26 # include "bench-string.h"
33 typedef char *(*proto_t
) (char *, const char *, size_t);
36 do_one_test (json_ctx_t
*json_ctx
, impl_t
*impl
, char *dst
, const char *src
,
40 timing_t start
, stop
, cur
;
43 for (i
= 0; i
< iters
; ++i
)
45 CALL (impl
, dst
, src
, len
);
49 TIMING_DIFF (cur
, start
, stop
);
51 json_element_double (json_ctx
, (double) cur
/ (double) iters
);
55 do_test (json_ctx_t
*json_ctx
, size_t align1
, size_t align2
, size_t len
,
62 if (align1
+ len
>= page_size
)
66 if (align2
+ len
>= page_size
)
69 s1
= (char *) (buf1
+ align1
);
70 s2
= (char *) (buf2
+ align2
);
72 for (repeats
= both_ways
? 2 : 1; repeats
; --repeats
)
74 for (i
= 0, j
= 1; i
< len
; i
++, j
+= 23)
77 json_element_object_begin (json_ctx
);
78 json_attr_uint (json_ctx
, "length", (double) len
);
79 json_attr_uint (json_ctx
, "align1", (double) align1
);
80 json_attr_uint (json_ctx
, "align2", (double) align2
);
81 json_attr_uint (json_ctx
, "dst > src", (double) (s2
> s1
));
82 json_array_begin (json_ctx
, "timings");
84 FOR_EACH_IMPL (impl
, 0)
85 do_one_test (json_ctx
, impl
, s2
, s1
, len
);
87 json_array_end (json_ctx
);
88 json_element_object_end (json_ctx
);
90 s1
= (char *) (buf2
+ align1
);
91 s2
= (char *) (buf1
+ align2
);
103 json_init (&json_ctx
, 0, stdout
);
105 json_document_begin (&json_ctx
);
106 json_attr_string (&json_ctx
, "timing_type", TIMING_TYPE
);
108 json_attr_object_begin (&json_ctx
, "functions");
109 json_attr_object_begin (&json_ctx
, TEST_NAME
);
110 json_attr_string (&json_ctx
, "bench-variant", "large");
112 json_array_begin (&json_ctx
, "ifuncs");
113 FOR_EACH_IMPL (impl
, 0)
114 json_element_string (&json_ctx
, impl
->name
);
115 json_array_end (&json_ctx
);
117 json_array_begin (&json_ctx
, "results");
118 for (i
= START_SIZE
; i
<= MIN_PAGE_SIZE
; i
<<= 1)
120 do_test (&json_ctx
, 0, 0, i
+ 7, 1);
121 do_test (&json_ctx
, 0, 3, i
+ 15, 1);
122 do_test (&json_ctx
, 3, 0, i
+ 31, 1);
123 do_test (&json_ctx
, 3, 5, i
+ 63, 1);
124 do_test (&json_ctx
, 0, 127, i
, 1);
125 do_test (&json_ctx
, 0, 255, i
, 1);
126 do_test (&json_ctx
, 0, 256, i
, 1);
127 do_test (&json_ctx
, 0, 4064, i
, 1);
130 json_array_end (&json_ctx
);
131 json_attr_object_end (&json_ctx
);
132 json_attr_object_end (&json_ctx
);
133 json_document_end (&json_ctx
);
138 #include <support/test-driver.c>