2 Copyright © 2008-2014, The AROS Development Team. All rights reserved.
11 #define BUFSIZE 1000000UL
12 char *src
= malloc(BUFSIZE
);
13 char *dst
= malloc(BUFSIZE
);
15 if (src
== NULL
|| dst
== NULL
)
18 #define BENCHMARK(z, n, c) memcpy(dst, src, BUFSIZE);
19 BENCHMARK_BUFFER(memcpy
,1000, BUFSIZE
);
22 #define BENCHMARK(z, n, c) memmove(dst, src, BUFSIZE);
23 BENCHMARK_BUFFER(memmove
,1000, BUFSIZE
);
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
);
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
);
37 #define BENCHMARK(z, n, c) memset(dst, 'b', BUFSIZE);
38 BENCHMARK_BUFFER(memset
,1000, BUFSIZE
);
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
);
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
);
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
);
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
);