Added 'Resident' field to ensure that the handler is included in the
[AROS.git] / test / benchmarks / clib / string.c
blob6226ba8a777720d47607db8e5f57cfa0e1b4a92c
1 /*
2 Copyright © 2008, 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[BUFSIZE];
13 char dst[BUFSIZE];
15 #define BENCHMARK(z, n, c) memcpy(dst, src, BUFSIZE);
16 BENCHMARK_BUFFER(memcpy,1000, BUFSIZE);
17 #undef BENCHMARK
19 #define BENCHMARK(z, n, c) memmove(dst, src, BUFSIZE);
20 BENCHMARK_BUFFER(memmove,1000, BUFSIZE);
21 #undef BENCHMARK
23 #define BENCHMARK(z, n, c) do { int res ## n = memcmp(dst, src, BUFSIZE); res ## n = 0; (void)res ## n; } while (0);
24 memset(src, 'a', BUFSIZE);
25 memset(dst, 'a', BUFSIZE);
26 BENCHMARK_BUFFER(memcmp,1000, BUFSIZE);
27 #undef BENCHMARK
29 #define BENCHMARK(z, n, c) do { char *res ## n = memchr(dst, 'b', BUFSIZE); res ## n = NULL; (void)res ## n; } while (0);
30 memset(src, 'a', BUFSIZE);
31 BENCHMARK_BUFFER(memchr,1000, BUFSIZE);
32 #undef BENCHMARK
34 #define BENCHMARK(z, n, c) memset(dst, 'b', BUFSIZE);
35 BENCHMARK_BUFFER(memset,1000, BUFSIZE);
36 #undef BENCHMARK
38 #define BENCHMARK(z, n, c) do { int res ## n = strlen(dst); res ## n = 0; (void)res ## n; } while (0);
39 memset(dst, 'a', BUFSIZE);
40 dst[BUFSIZE - 1] = '\0';
41 BENCHMARK_BUFFER(strlen,1000, BUFSIZE);
42 #undef BENCHMARK
44 #define BENCHMARK(z, n, c) strncpy(dst, src, BUFSIZE);
45 memset(src, 'a', BUFSIZE);
46 memset(dst, 'a', BUFSIZE);
47 BENCHMARK_BUFFER(strncpy,1000, BUFSIZE);
48 #undef BENCHMARK
50 #define BENCHMARK(z, n, c) do { int res ## n = strncmp(dst, src, BUFSIZE); res ## n = 0; (void)res ## n; } while (0);
51 memset(src, 'a', BUFSIZE);
52 memset(dst, 'a', BUFSIZE);
53 BENCHMARK_BUFFER(strncmp,1000, BUFSIZE);
54 #undef BENCHMARK
56 #define BENCHMARK(z, n, c) do { int res ## n = strncasecmp(dst, src, BUFSIZE); res ## n = 0; (void)res ## n; } while (0);
57 memset(src, 'a', BUFSIZE);
58 memset(dst, 'A', BUFSIZE);
59 BENCHMARK_BUFFER(strncasecmp,1000, BUFSIZE);
60 #undef BENCHMARK
62 return 1;