grub2: bring back build of aros-side grub2 tools
[AROS.git] / test / benchmarks / clib / string.c
blob6ad528d4fa4f64a85b5042b3ddf8e0774e4226e4
1 /*
2 Copyright © 2008-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "benchmark.h"
7 #include <string.h>
9 int main()
11 #define BUFSIZE 1000000UL
12 char *src = malloc(BUFSIZE);
13 char *dst = malloc(BUFSIZE);
15 if (src == NULL || dst == NULL)
16 return 1;
18 #define BENCHMARK(z, n, c) memcpy(dst, src, BUFSIZE);
19 BENCHMARK_BUFFER(memcpy,1000, BUFSIZE);
20 #undef BENCHMARK
22 #define BENCHMARK(z, n, c) memmove(dst, src, BUFSIZE);
23 BENCHMARK_BUFFER(memmove,1000, BUFSIZE);
24 #undef BENCHMARK
26 #define BENCHMARK(z, n, c) do { int res ## n = memcmp(dst, src, BUFSIZE); res ## n = 0; (void)res ## n; } while (0);
27 memset(src, 'a', BUFSIZE);
28 memset(dst, 'a', BUFSIZE);
29 BENCHMARK_BUFFER(memcmp,1000, BUFSIZE);
30 #undef BENCHMARK
32 #define BENCHMARK(z, n, c) do { char *res ## n = memchr(dst, 'b', BUFSIZE); res ## n = NULL; (void)res ## n; } while (0);
33 memset(src, 'a', BUFSIZE);
34 BENCHMARK_BUFFER(memchr,1000, BUFSIZE);
35 #undef BENCHMARK
37 #define BENCHMARK(z, n, c) memset(dst, 'b', BUFSIZE);
38 BENCHMARK_BUFFER(memset,1000, BUFSIZE);
39 #undef BENCHMARK
41 #define BENCHMARK(z, n, c) do { int res ## n = strlen(dst); res ## n = 0; (void)res ## n; } while (0);
42 memset(dst, 'a', BUFSIZE);
43 dst[BUFSIZE - 1] = '\0';
44 BENCHMARK_BUFFER(strlen,1000, BUFSIZE);
45 #undef BENCHMARK
47 #define BENCHMARK(z, n, c) strncpy(dst, src, BUFSIZE);
48 memset(src, 'a', BUFSIZE);
49 memset(dst, 'a', BUFSIZE);
50 BENCHMARK_BUFFER(strncpy,1000, BUFSIZE);
51 #undef BENCHMARK
53 #define BENCHMARK(z, n, c) do { int res ## n = strncmp(dst, src, BUFSIZE); res ## n = 0; (void)res ## n; } while (0);
54 memset(src, 'a', BUFSIZE);
55 memset(dst, 'a', BUFSIZE);
56 BENCHMARK_BUFFER(strncmp,1000, BUFSIZE);
57 #undef BENCHMARK
59 #define BENCHMARK(z, n, c) do { int res ## n = strncasecmp(dst, src, BUFSIZE); res ## n = 0; (void)res ## n; } while (0);
60 memset(src, 'a', BUFSIZE);
61 memset(dst, 'A', BUFSIZE);
62 BENCHMARK_BUFFER(strncasecmp,1000, BUFSIZE);
63 #undef BENCHMARK
65 return 1;