8#undef TIMING_END_AND_PRINT
9#undef TIMING_DEFINE_PRINT
10#undef TIMING_DEFINE_PRINTPROTO
15#if ! defined(WINNT) || defined(__GNUC__)
29#if ! defined (HZ) && defined (CLOCKS_PER_SEC)
30#define HZ CLOCKS_PER_SEC
32#if ! defined (HZ) && defined (CLK_TCK)
43#if defined(WINNT) && ! defined(__GNUC__)
45#define TIMING_DEFINE(t) static clock_t timing_ ## t ## _start, timing_ ## t ## _end; \
46static clock_t timing_ ## t ## _time;
47#define TIMING_START(t) timing_ ## t ## _start = clock();
48#define TIMING_END(t) timing_ ## t ## _end = clock(); \
49timing_ ## t ## _time += timing_ ## t ## _end - timing_ ## t ## _start;
50#define TIMING_END_AND_PRINT(t, msg) times( &timing_ ## t ## _end ); \
51 fprintf( stderr, "%s%.2f sec\n", msg, \
52 float( timing_ ## t ## _end - timing_ ## t ## _start ) / HZ ); \
53 timing_ ## t ## _time += timing_ ## t ## _end - timing_ ## t ## _start;
54#define TIMING_DEFINE_PRINT(t) static clock_t timing_ ## t ## _start, timing_ ## t ## _end; \
55static clock_t timing_ ## t ## _time; \
56static void timing_print_ ## t ( char * msg ) { \
57 fprintf( stderr, "%s%.2f sec\n", msg, float(timing_ ## t ## _time) / HZ ); \
59static void timing_reset_ ## t () { \
60 timing_ ## t ## _time = 0; \
65#define TIMING_DEFINE(t) static struct tms timing_ ## t ## _start, timing_ ## t ## _end; \
66static long timing_ ## t ## _time;
67#define TIMING_START(t) times( &timing_ ## t ## _start );
68#define TIMING_END(t) times( &timing_ ## t ## _end ); \
69 timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime;
70#define TIMING_END_AND_PRINT(t, msg) times( &timing_ ## t ## _end ); \
71 fprintf( stderr, "%s%.2f sec\n", msg, \
72 float( timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime ) / HZ ); \
73 timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime;
74#define TIMING_DEFINE_PRINT(t) static struct tms timing_ ## t ## _start, timing_ ## t ## _end; \
75static long timing_ ## t ## _time; \
76static void timing_print_ ## t ( char * msg ) { \
77 fprintf( stderr, "%s%.2f sec\n", msg, float(timing_ ## t ## _time) / HZ ); \
79static void timing_reset_ ## t () { \
80 timing_ ## t ## _time = 0; \
85#define TIMING_DEFINE_PRINTPROTO(t) void timing_print_ ## t ( char * ); \
86 void timing_reset_ ## t ();
87#define TIMING_PRINT(t, msg) timing_print_ ## t ( msg );
88#define TIMING_RESET(t) timing_reset_ ## t ();
91#define TIMING_DEFINE(t)
92#define TIMING_START(t)
94#define TIMING_END_AND_PRINT(t, msg)
95#define TIMING_DEFINE_PRINT(t)
96#define TIMING_DEFINE_PRINTPROTO(t)
97#define TIMING_PRINT(t, msg)
98#define TIMING_RESET(t)