Utility benchmarking macros
This new macros could be used to benchmark overall
execution time of some chunk of code, running in cycle.
The usage is:
void foo(void) {
TIMEIT_BLOCK_INIT(overall_bar);
for (...) {
...
TIMEIT_BLOCK_BEGIN(over_bar);
bar();
TIMEIT_BLOCK_END(oberall_bar);
...
}
TIMEIT_BLOCK_STATS(overall_bar)
}
This would print total time which was spent on
running function bar().
--
svn merge -r58281:58283 ^/branches/soc-2013-depsgraph_mt
This commit is contained in:
@@ -87,6 +87,26 @@ void PIL_sleep_ms(int ms);
|
||||
TIMEIT_END(id); \
|
||||
} (void)0
|
||||
|
||||
#define TIMEIT_BLOCK_INIT(what) \
|
||||
double _timeit_var_##what = 0; \
|
||||
(void) 0
|
||||
|
||||
#define TIMEIT_BLOCK_BEGIN(what) \
|
||||
{ \
|
||||
double _timeit_block_start_##what = PIL_check_seconds_timer(); \
|
||||
{ (void)0
|
||||
|
||||
#define TIMEIT_BLOCK_END(what) \
|
||||
} \
|
||||
_timeit_var_##what += PIL_check_seconds_timer() - _timeit_block_start_##what; \
|
||||
} (void)0
|
||||
|
||||
#define TIMEIT_BLOCK_STATS(what) \
|
||||
{ \
|
||||
printf("%s time (in seconds): %f\n", #what, _timeit_var_##what); \
|
||||
fflush(stdout); \
|
||||
} (void)0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user