[Bf-blender-cvs] [cc0f5bf] master: Cleanup: make use of PIL time instead of redefining own timers.

Kévin Dietrich noreply at git.blender.org
Sat Jan 9 04:25:58 CET 2016


Commit: cc0f5bf7ec4a072994633294b4cbea0cd7472a07
Author: Kévin Dietrich
Date:   Sat Jan 9 04:25:48 2016 +0100
Branches: master
https://developer.blender.org/rBcc0f5bf7ec4a072994633294b4cbea0cd7472a07

Cleanup: make use of PIL time instead of redefining own timers.

Also added a DEBUG_TIME macro in the related files to comment time funcs out.

Reviewers: brecht

Reviewed By: brecht

Subscribers: brecht

Differential Revision: https://developer.blender.org/D1717

===================================================================

M	source/blender/blenkernel/intern/smoke.c
M	source/blender/physics/intern/implicit_blender.c

===================================================================

diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 29ae04b..dae4a60 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -90,57 +90,18 @@
 /* UNUSED so far, may be enabled later */
 /* #define USE_SMOKE_COLLISION_DM */
 
+//#define DEBUG_TIME
+
+#ifdef DEBUG_TIME
+#	include "PIL_time.h"
+#endif
+
 #include "smoke_API.h"
 
 #ifdef WITH_SMOKE
 
 static ThreadMutex object_update_lock = BLI_MUTEX_INITIALIZER;
 
-#ifdef _WIN32
-#include <time.h>
-#include <stdio.h>
-#include <conio.h>
-#include <windows.h>
-
-static LARGE_INTEGER liFrequency;
-static LARGE_INTEGER liStartTime;
-static LARGE_INTEGER liCurrentTime;
-
-static void tstart(void)
-{
-	QueryPerformanceFrequency(&liFrequency);
-	QueryPerformanceCounter(&liStartTime);
-}
-static void tend(void)
-{
-	QueryPerformanceCounter(&liCurrentTime);
-}
-static double UNUSED_FUNCTION(tval) (void)
-{
-	return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart) * (double)1000.0 / (double)liFrequency.QuadPart));
-}
-#else
-#include <sys/time.h>
-static struct timeval _tstart, _tend;
-static struct timezone tz;
-static void tstart(void)
-{
-	gettimeofday(&_tstart, &tz);
-}
-static void tend(void)
-{
-	gettimeofday(&_tend, &tz);
-}
-
-static double UNUSED_FUNCTION(tval) (void)
-{
-	double t1, t2;
-	t1 = ( double ) _tstart.tv_sec * 1000 + ( double ) _tstart.tv_usec / (1000);
-	t2 = ( double ) _tend.tv_sec * 1000 + ( double ) _tend.tv_usec / (1000);
-	return t2 - t1;
-}
-#endif
-
 struct Object;
 struct Scene;
 struct DerivedMesh;
@@ -806,8 +767,6 @@ static void obstacles_from_derivedmesh(
 		float *vert_vel = NULL;
 		bool has_velocity = false;
 
-		tstart();
-
 		dm = CDDM_copy(scs->dm);
 		CDDM_calc_normals(dm);
 		mvert = dm->getVertArray(dm);
@@ -2858,7 +2817,9 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
 		if (framenr != scene->r.cfra)
 			return;
 
-		tstart();
+#ifdef DEBUG_TIME
+		double start = PIL_check_seconds_timer();
+#endif
 
 		/* if on second frame, write cache for first frame */
 		if ((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact == 0)) {
@@ -2899,8 +2860,10 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
 		if (framenr != startframe)
 			BKE_ptcache_write(&pid, framenr);
 
-		tend();
-		// printf ( "Frame: %d, Time: %f\n\n", (int)smd->time, (float) tval() );
+#ifdef DEBUG_TIME
+		double end = PIL_check_seconds_timer();
+		printf("Frame: %d, Time: %f\n\n", (int)smd->time, (float)(end - start));
+#endif
 	}
 }
 
diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c
index 0fd2a1f..11efabf 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -60,55 +60,11 @@
 #  define CLOTH_OPENMP_LIMIT 512
 #endif
 
-#if 0  /* debug timing */
-#ifdef _WIN32
-#include <windows.h>
-static LARGE_INTEGER _itstart, _itend;
-static LARGE_INTEGER ifreq;
-static void itstart(void)
-{
-	static int first = 1;
-	if (first) {
-		QueryPerformanceFrequency(&ifreq);
-		first = 0;
-	}
-	QueryPerformanceCounter(&_itstart);
-}
-static void itend(void)
-{
-	QueryPerformanceCounter(&_itend);
-}
-double itval(void)
-{
-	return ((double)_itend.QuadPart -
-	        (double)_itstart.QuadPart)/((double)ifreq.QuadPart);
-}
-#else
-#include <sys/time.h>
-// intrinsics need better compile flag checking
-// #include <xmmintrin.h>
-// #include <pmmintrin.h>
-// #include <pthread.h>
+//#define DEBUG_TIME
 
-static struct timeval _itstart, _itend;
-static struct timezone itz;
-static void itstart(void)
-{
-	gettimeofday(&_itstart, &itz);
-}
-static void itend(void)
-{
-	gettimeofday(&_itend, &itz);
-}
-static double itval(void)
-{
-	double t1, t2;
-	t1 =  (double)_itstart.tv_sec + (double)_itstart.tv_usec/(1000*1000);
-	t2 =  (double)_itend.tv_sec + (double)_itend.tv_usec/(1000*1000);
-	return t2-t1;
-}
+#ifdef DEBUG_TIME
+#	include "PIL_time.h"
 #endif
-#endif  /* debug timing */
 
 static float I[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
 static float ZERO[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
@@ -989,7 +945,9 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
 	
 	delta0 = deltaNew * sqrt(conjgrad_epsilon);
 	
-	// itstart();
+#ifdef DEBUG_TIME
+	double start = PIL_check_seconds_timer();
+#endif
 	
 	while ((deltaNew > delta0) && (iterations < conjgrad_looplimit))
 	{
@@ -1016,9 +974,11 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
 		filter(p, S);
 		
 	}
-	
-	// itend();
-	// printf("cg_filtered_pre time: %f\n", (float)itval());
+
+#ifdef DEBUG_TIME
+	double end = PIL_check_seconds_timer();
+	printf("cg_filtered_pre time: %f\n", (float)(end - start));
+#endif
 	
 	del_lfvector(h);
 	del_lfvector(s);
@@ -1087,8 +1047,10 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
 	
 	delta0 = deltaNew * sqrt(conjgrad_epsilon);
 	*/
-	
-	// itstart();
+
+#ifdef DEBUG_TIME
+	double start = PIL_check_seconds_timer();
+#endif
 	
 	tol = (0.01*0.2);
 	
@@ -1117,10 +1079,12 @@ static int cg_filtered_pre(lfVector *dv, fmatrix3x3 *lA, lfVector *lB, lfVector
 		filter(p, S);
 		
 	}
-	
-	// itend();
-	// printf("cg_filtered_pre time: %f\n", (float)itval());
-	
+
+#ifdef DEBUG_TIME
+	double end = PIL_check_seconds_timer();
+	printf("cg_filtered_pre time: %f\n", (float)(end - start));
+#endif
+
 	del_lfvector(btemp);
 	del_lfvector(bhat);
 	del_lfvector(h);
@@ -1149,13 +1113,17 @@ bool BPH_mass_spring_solve_velocities(Implicit_Data *data, float dt, ImplicitSol
 
 	add_lfvectorS_lfvectorS(data->B, data->F, dt, dFdXmV, (dt*dt), numverts);
 
-	// itstart();
+#ifdef DEBUG_TIME
+	double start = PIL_check_seconds_timer();
+#endif
 
 	cg_filtered(data->dV, data->A, data->B, data->z, data->S, result); /* conjugate gradient algorithm to solve Ax=b */
 	// cg_filtered_pre(id->dV, id->A, id->B, id->z, id->S, id->P, id->Pinv, id->bigI);
 
-	// itend();
-	// printf("cg_filtered calc time: %f\n", (float)itval());
+#ifdef DEBUG_TIME
+	double end = PIL_check_seconds_timer();
+	printf("cg_filtered calc time: %f\n", (float)(end - start));
+#endif
 
 	// advance velocities
 	add_lfvector_lfvector(data->Vnew, data->V, data->dV, numverts);




More information about the Bf-blender-cvs mailing list