platform.texi: Move LAM after LAHF64_SAHF64
[glibc.git] / benchtests / bench-memmove-large.c
bloba09dd3678848a3bf8612732439700eb8ef5d82ea
1 /* Measure memmove functions with large data sizes.
2 Copyright (C) 2016-2023 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/>. */
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"
26 #include "json-lib.h"
28 IMPL (memmove, 1)
30 typedef char *(*proto_t) (char *, const char *, size_t);
32 static void
33 do_one_test (json_ctx_t *json_ctx, impl_t *impl, char *dst, char *src,
34 size_t len)
36 size_t i, iters = 16;
37 timing_t start, stop, cur;
39 TIMING_NOW (start);
40 for (i = 0; i < iters; ++i)
42 CALL (impl, dst, src, len);
44 TIMING_NOW (stop);
46 TIMING_DIFF (cur, start, stop);
48 json_element_double (json_ctx, (double) cur / (double) iters);
51 static void
52 do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
54 size_t i, j;
55 char *s1, *s2;
57 align1 &= 127;
58 if (align1 + len >= page_size)
59 return;
61 align2 &= 127;
62 if (align2 + len >= page_size)
63 return;
65 s1 = (char *) (buf2 + align1);
66 s2 = (char *) (buf2 + align2);
68 for (i = 0, j = 1; i < len; i++, j += 23)
69 s1[i] = j;
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");
77 FOR_EACH_IMPL (impl, 0)
78 do_one_test (json_ctx, impl, s2, s1, len);
80 json_array_end (json_ctx);
81 json_element_object_end (json_ctx);
84 int
85 test_main (void)
87 json_ctx_t json_ctx;
88 size_t i;
90 test_init ();
92 json_init (&json_ctx, 0, stdout);
94 json_document_begin (&json_ctx);
95 json_attr_string (&json_ctx, "timing_type", TIMING_TYPE);
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");
101 json_array_begin (&json_ctx, "ifuncs");
103 FOR_EACH_IMPL (impl, 0)
104 json_element_string (&json_ctx, impl->name);
105 json_array_end (&json_ctx);
107 json_array_begin (&json_ctx, "results");
108 for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
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);
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);
122 return ret;
125 #include <support/test-driver.c>