From 8f6e5776207a473366bc2307226f329153819460 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 Mar 2011 04:35:36 +0000 Subject: Utility defines for quick timing tests. for most cases: TIMEIT_START(my_test) .... TIMEIT_END(my_test) prints time, test name, function name and line number. --- source/blender/blenlib/PIL_time.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source/blender/blenlib/PIL_time.h') diff --git a/source/blender/blenlib/PIL_time.h b/source/blender/blenlib/PIL_time.h index b44b7c742f9..df54b53e22e 100644 --- a/source/blender/blenlib/PIL_time.h +++ b/source/blender/blenlib/PIL_time.h @@ -56,9 +56,29 @@ double PIL_check_seconds_timer (void); */ void PIL_sleep_ms (int ms); +/** Utility defines for timing. + * requires BLI_utildefines.h for 'AT' + * TIMEIT_VALUE returns the time since TIMEIT_START was called. + */ +#define TIMEIT_START(var) \ +{ \ + double _timeit_##var= PIL_check_seconds_timer(); \ + printf("time start (" #var "): " AT "\n"); \ + fflush(stdout); \ + { \ + + +#define TIMEIT_VALUE(var) (float)(PIL_check_seconds_timer() - _timeit_##var) + + +#define TIMEIT_END(var) \ + } \ + printf("time end (" #var "): %.6f" " " AT "\n", TIMEIT_VAL(var)); \ + fflush(stdout); \ +} \ + #ifdef __cplusplus } #endif -#endif - +#endif /* !PIL_TIME_H */ -- cgit v1.2.3