]>
git.ipfire.org Git - thirdparty/glibc.git/blob - benchtests/bench-memset-large.c
1 /* Measure memset functions with large data sizes.
2 Copyright (C) 2016-2017 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/>. */
21 # define TEST_NAME "memset"
23 # define TEST_NAME "wmemset"
25 #define START_SIZE (128 * 1024)
26 #define MIN_PAGE_SIZE (getpagesize () + 64 * 1024 * 1024)
27 #define TIMEOUT (20 * 60)
28 #include "bench-string.h"
31 # define MEMSET memset
33 # define SIMPLE_MEMSET simple_memset
34 # define MEMCMP memcmp
37 # define MEMSET wmemset
39 # define SIMPLE_MEMSET simple_wmemset
40 # define MEMCMP wmemcmp
47 typedef CHAR
*(*proto_t
) (CHAR
*, int, size_t);
50 inhibit_loop_to_libcall
51 SIMPLE_MEMSET (CHAR
*s
, int c
, size_t n
)
53 CHAR
*r
= s
, *end
= s
+ n
;
60 do_one_test (impl_t
*impl
, CHAR
*s
, int c
__attribute ((unused
)), size_t n
)
63 timing_t start
, stop
, cur
;
66 for (i
= 0; i
< iters
; ++i
)
72 TIMING_DIFF (cur
, start
, stop
);
74 TIMING_PRINT_MEAN ((double) cur
, (double) iters
);
78 do_test (size_t align
, int c
, size_t len
)
81 if ((align
+ len
) * sizeof (CHAR
) > page_size
)
84 printf ("Length %4zd, alignment %2zd, c %2d:", len
, align
, c
);
86 FOR_EACH_IMPL (impl
, 0)
87 do_one_test (impl
, (CHAR
*) (buf1
) + align
, c
, len
);
101 FOR_EACH_IMPL (impl
, 0)
102 printf ("\t%s", impl
->name
);
106 for (i
= START_SIZE
; i
<= MIN_PAGE_SIZE
; i
<<= 1)
115 #include <support/test-driver.c>