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)
23 #define TEST_NAME "memmove"
24 #define TIMEOUT (20 * 60)
25 #include "bench-string.h"
29 typedef char *(*proto_t
) (char *, const char *, size_t);
32 do_one_test (impl_t
*impl
, char *dst
, char *src
, const char *orig_src
,
36 timing_t start
, stop
, cur
;
38 /* This also clears the destination buffer updated by the previous
40 memcpy (src
, orig_src
, len
);
42 char *res
= CALL (impl
, dst
, src
, len
);
45 error (0, 0, "Wrong result in function %s %p %p", impl
->name
,
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
);
60 for (i
= 0; i
< iters
; ++i
)
62 CALL (impl
, dst
, src
, len
);
66 TIMING_DIFF (cur
, start
, stop
);
68 TIMING_PRINT_MEAN ((double) cur
, (double) iters
);
72 do_test (size_t align1
, size_t align2
, size_t len
)
78 if (align1
+ len
>= page_size
)
82 if (align2
+ len
>= page_size
)
85 s1
= (char *) (buf1
+ align1
);
86 s2
= (char *) (buf2
+ align2
);
88 for (i
= 0, j
= 1; i
< len
; i
++, j
+= 23)
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
);
107 FOR_EACH_IMPL (impl
, 0)
108 printf ("\t%s", impl
->name
);
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);
123 #include "../test-skeleton.c"