move timeit macros into their own include, since they are only used for testing and...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 3 Sep 2013 21:22:43 +0000 (21:22 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 3 Sep 2013 21:22:43 +0000 (21:22 +0000)
source/blender/blenlib/CMakeLists.txt
source/blender/blenlib/PIL_time.h
source/blender/blenlib/PIL_time_utildefines.h [new file with mode: 0644]
source/blender/bmesh/operators/bmo_beautify.c
source/blender/editors/space_view3d/drawvolume.c
source/blender/modifiers/intern/MOD_decimate.c
source/blender/modifiers/intern/MOD_weightvgproximity.c

index 70665521ca8550b5d62940a9522ef47c0eb4525b..9ca56d60593d86748a95c80fb35e1843797a65ed 100644 (file)
@@ -162,6 +162,7 @@ set(SRC
        BLI_voxel.h
        BLI_winstuff.h
        PIL_time.h
+       PIL_time_utildefines.h
 )
 
 if(WITH_BINRELOC)
index 3983b5099ff98b2bbb6d90eee30266821dad6171..158559fa3d96c3dff9932ad35651f88054836b6e 100644 (file)
@@ -51,64 +51,8 @@ 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);                                                       \
-               { (void)0
-
-#define TIMEIT_VALUE(var) (float)(PIL_check_seconds_timer() - _timeit_##var)
-
-#define TIMEIT_VALUE_PRINT(var)                                               \
-       {                                                                         \
-               printf("time update(" #var "): %.6f" "  " AT "\n", TIMEIT_VALUE(var));\
-               fflush(stdout);                                                       \
-       } (void)0
-
-#define TIMEIT_END(var)                                                       \
-       }                                                                         \
-       printf("time end   (" #var "): %.6f" "  " AT "\n", TIMEIT_VALUE(var));    \
-       fflush(stdout);                                                           \
-} (void)0
-
-/**
- * Given some function/expression:
- *   TIMEIT_BENCH(some_function(), some_unique_description);
- */
-#define TIMEIT_BENCH(expr, id)                                                \
-       {                                                                         \
-               TIMEIT_START(id);                                                     \
-               (expr);                                                               \
-               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
 
-#endif  /* !__PIL_TIME_H__ */
+#endif  /* __PIL_TIME_H__ */
diff --git a/source/blender/blenlib/PIL_time_utildefines.h b/source/blender/blenlib/PIL_time_utildefines.h
new file mode 100644 (file)
index 0000000..c253aba
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2013 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Campbell Barton
+ *                 Sergey Sharybin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenlib/PIL_time_utildefines.h
+ *  \ingroup bli
+ *  \brief Utility defines for timing/benchmarks.
+ *
+ * \note requires BLI_utildefines.h for 'AT'.
+ */
+
+#ifndef __PIL_TIME_UTILDEFINES_H__
+#define __PIL_TIME_UTILDEFINES_H__
+
+#define TIMEIT_START(var)                                                     \
+       {                                                                         \
+               double _timeit_##var = PIL_check_seconds_timer();                     \
+               printf("time start (" #var "):  " AT "\n");                           \
+               fflush(stdout);                                                       \
+               { (void)0
+
+/**
+ * \return the time since TIMEIT_START was called.
+ */
+#define TIMEIT_VALUE(var) (float)(PIL_check_seconds_timer() - _timeit_##var)
+
+#define TIMEIT_VALUE_PRINT(var)                                               \
+       {                                                                         \
+               printf("time update(" #var "): %.6f" "  " AT "\n", TIMEIT_VALUE(var));\
+               fflush(stdout);                                                       \
+       } (void)0
+
+#define TIMEIT_END(var)                                                       \
+       }                                                                         \
+       printf("time end   (" #var "): %.6f" "  " AT "\n", TIMEIT_VALUE(var));    \
+       fflush(stdout);                                                           \
+} (void)0
+
+/**
+ * Given some function/expression:
+ *   TIMEIT_BENCH(some_function(), some_unique_description);
+ */
+#define TIMEIT_BENCH(expr, id)                                                \
+       {                                                                         \
+               TIMEIT_START(id);                                                     \
+               (expr);                                                               \
+               TIMEIT_END(id);                                                       \
+       } (void)0
+
+#define TIMEIT_BLOCK_INIT(id) \
+       double _timeit_var_##id = 0; \
+       (void) 0
+
+#define TIMEIT_BLOCK_START(id)                                                \
+       {                                                                         \
+               double _timeit_block_start_##id = PIL_check_seconds_timer();          \
+               { (void)0
+
+#define TIMEIT_BLOCK_END(id)                                                  \
+               }                                                                     \
+               _timeit_var_##id += (PIL_check_seconds_timer() -                      \
+                                    _timeit_block_start_##id);                       \
+       } (void)0
+
+#define TIMEIT_BLOCK_STATS(id)                                                \
+       {                                                                         \
+               printf("%s time (in seconds): %f\n", #id, _timeit_var_##id);          \
+               fflush(stdout);                                                       \
+       } (void)0
+
+#endif  /* __PIL_TIME_UTILDEFINES_H__ */
index 3dbdb3ddc52a805f599259ddc8ec2d96750d3a3e..a6d781c20660dd4a63e939d5bf043f72ba20d8a8 100644 (file)
@@ -47,6 +47,7 @@
 
 #ifdef DEBUG_TIME
 #  include "PIL_time.h"
+#  include "PIL_time_utildefines.h"
 #endif
 
 enum {
index 542ed7af0e605fec8e9ccfce4362aa8b88167266..a7940faa47dc6f9f7553a9c429841d7f51c9333c 100644 (file)
@@ -83,6 +83,7 @@ struct GPUTexture;
 
 #ifdef DEBUG_DRAW_TIME
 #  include "PIL_time.h"
+#  include "PIL_time_utildefines.h"
 #endif
 
 static int intersect_edges(float *points, float a, float b, float c, float d, float edges[12][2][3])
index 69988f32da95269a9213ca2a8c5b26098623553c..a3569cbde68501df0ef85b9d85a55fd2b808b055 100644 (file)
@@ -55,6 +55,7 @@
 
 #ifdef USE_TIMEIT
 #  include "PIL_time.h"
+#  include "PIL_time_utildefines.h"
 #endif
 
 #include "MOD_util.h"
index 632675385284d6cedd4d71ea4b2ae450c5370d6f..67168e529498d7353ea23fbf092b1db8c6081b03 100644 (file)
  *  \ingroup modifiers
  */
 
-#define DO_PROFILE 0
-
 #include "BLI_utildefines.h"
 #include "BLI_ghash.h"
 #include "BLI_math.h"
 #include "BLI_string.h"
 #include "BLI_rand.h"
 
-#if DO_PROFILE
-       #include "PIL_time.h"
-#endif
-
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
 #include "MOD_util.h"
 #include "MOD_weightvg_util.h"
 
+// #define USE_TIMEIT
+
+#ifdef USE_TIMEIT
+#  include "PIL_time.h"
+#  include "PIL_time_utildefines.h"
+#endif
+
 /**************************************
  * Util functions.                    *
  **************************************/
@@ -382,8 +383,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
        int do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview);
 #endif
 
-#if DO_PROFILE
-       TIMEIT_START(perf)
+#ifdef USE_TIMEIT
+       TIMEIT_START(perf);
 #endif
 
        /* Get number of verts. */
@@ -548,8 +549,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
                MEM_freeN(indices);
        MEM_freeN(v_cos);
 
-#if DO_PROFILE
-       TIMEIT_END(perf)
+#ifdef USE_TIMEIT
+       TIMEIT_END(perf);
 #endif
 
        /* Return the vgroup-modified mesh. */