Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-08-19 14:16:23 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-08-19 14:16:23 +0400
commit552d068565172a2b7eaa538cb1c343e098715e4e (patch)
tree4390e1581634323fe5f79356c1122b6c83b79116 /source/blender/blenlib/PIL_time.h
parent36ffc7accde82eb1d1930ed8758e315339fac8bc (diff)
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
Diffstat (limited to 'source/blender/blenlib/PIL_time.h')
-rw-r--r--source/blender/blenlib/PIL_time.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenlib/PIL_time.h b/source/blender/blenlib/PIL_time.h
index c3e7e8486d9..3983b5099ff 100644
--- a/source/blender/blenlib/PIL_time.h
+++ b/source/blender/blenlib/PIL_time.h
@@ -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