[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58282] branches/soc-2013-depsgraph_mt/ source/blender: Utility benchmarking macros

Sergey Sharybin sergey.vfx at gmail.com
Mon Jul 15 21:17:45 CEST 2013


Revision: 58282
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58282
Author:   nazgul
Date:     2013-07-15 19:17:45 +0000 (Mon, 15 Jul 2013)
Log Message:
-----------
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().

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/scene.c
    branches/soc-2013-depsgraph_mt/source/blender/blenlib/PIL_time.h

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/scene.c	2013-07-15 19:04:49 UTC (rev 58281)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/scene.c	2013-07-15 19:17:45 UTC (rev 58282)
@@ -87,6 +87,8 @@
 
 #include "RE_engine.h"
 
+#include "PIL_time.h"
+
 #include "IMB_colormanagement.h"
 
 //XXX #include "BIF_previewrender.h"

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenlib/PIL_time.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenlib/PIL_time.h	2013-07-15 19:04:49 UTC (rev 58281)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenlib/PIL_time.h	2013-07-15 19:17:45 UTC (rev 58282)
@@ -87,6 +87,26 @@
 		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




More information about the Bf-blender-cvs mailing list