Manual typos: Library Maintenance
[glibc.git] / benchtests / bench-memmove-large.c
blobb8f11c1f193b2f53c1a731f74c5da502d5505a1e
1 /* Measure memmove functions with large data sizes.
2 Copyright (C) 2016 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 <http://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"
27 IMPL (memmove, 1)
29 typedef char *(*proto_t) (char *, const char *, size_t);
31 static void
32 do_one_test (impl_t *impl, char *dst, char *src, const char *orig_src,
33 size_t len)
35 size_t i, iters = 16;
36 timing_t start, stop, cur;
38 /* This also clears the destination buffer updated by the previous
39 run. */
40 memcpy (src, orig_src, len);
42 char *res = CALL (impl, dst, src, len);
43 if (res != dst)
45 error (0, 0, "Wrong result in function %s %p %p", impl->name,
46 res, dst);
47 ret = 1;
48 return;
51 if (memcmp (dst, orig_src, len) != 0)
53 error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"",
54 impl->name, dst, src);
55 ret = 1;
56 return;
59 TIMING_NOW (start);
60 for (i = 0; i < iters; ++i)
62 CALL (impl, dst, src, len);
64 TIMING_NOW (stop);
66 TIMING_DIFF (cur, start, stop);
68 TIMING_PRINT_MEAN ((double) cur, (double) iters);
71 static void
72 do_test (size_t align1, size_t align2, size_t len)
74 size_t i, j;
75 char *s1, *s2;
77 align1 &= 127;
78 if (align1 + len >= page_size)
79 return;
81 align2 &= 127;
82 if (align2 + len >= page_size)
83 return;
85 s1 = (char *) (buf1 + align1);
86 s2 = (char *) (buf2 + align2);
88 for (i = 0, j = 1; i < len; i++, j += 23)
89 s1[i] = j;
91 printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
93 FOR_EACH_IMPL (impl, 0)
94 do_one_test (impl, s2, (char *) (buf2 + align1), s1, len);
96 putchar ('\n');
99 int
100 test_main (void)
102 size_t i;
104 test_init ();
106 printf ("%23s", "");
107 FOR_EACH_IMPL (impl, 0)
108 printf ("\t%s", impl->name);
109 putchar ('\n');
111 for (i = START_SIZE; i <= MIN_PAGE_SIZE; i <<= 1)
113 do_test (0, 64, i + 7);
114 do_test (0, 3, i + 15);
115 do_test (3, 0, i + 31);
116 do_test (3, 7, i + 63);
117 do_test (9, 5, i + 127);
120 return ret;
123 #include "../test-skeleton.c"