2 Copyright © 2008, The AROS Development Team. All rights reserved.
6 #include <boost/preprocessor/repetition/repeat.hpp>
12 struct timeval name ## _start; \
13 struct timeval name ## _stop
15 #define START(name) gettimeofday(& name ## _start, NULL);
17 #define STOP(name) gettimeofday(& name ## _stop, NULL);
19 #define ELAPSED(name) ((double)(((name ## _stop.tv_sec * 1000000) + name ## _stop.tv_usec) - ((name ## _start.tv_sec * 1000000) + name ## _start.tv_usec))/1000000.0)
21 #define BENCHMARK_UNIVERSAL(name, count, bufsize) \
25 for(name ## _i = 0; name ## _i < count/100; name ## _i++) { \
26 BOOST_PP_REPEAT(100, BENCHMARK,name ## _i); \
30 #define BENCHMARK_OPERATION(name, count) \
31 BENCHMARK_UNIVERSAL(name, count, 1); \
32 printf(#name " %.2lf operations/s\n", 1.0 * count / ELAPSED(name));
35 #define BENCHMARK_BUFFER(name, count, bufsize) \
36 BENCHMARK_UNIVERSAL(name, count, bufsize) \
37 printf(#name " %.2lf bytes/s\n", 1.0 * bufsize * count / ELAPSED(name));