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:
Diffstat (limited to 'extern/bullet2/src/LinearMath/btQuickprof.h')
-rw-r--r--extern/bullet2/src/LinearMath/btQuickprof.h109
1 files changed, 66 insertions, 43 deletions
diff --git a/extern/bullet2/src/LinearMath/btQuickprof.h b/extern/bullet2/src/LinearMath/btQuickprof.h
index ec560c8e33e..9389fcd8156 100644
--- a/extern/bullet2/src/LinearMath/btQuickprof.h
+++ b/extern/bullet2/src/LinearMath/btQuickprof.h
@@ -22,16 +22,16 @@ subject to the following restrictions:
#ifndef QUICK_PROF_H
#define QUICK_PROF_H
-#define USE_QUICKPROF 1
+#include "btScalar.h"
-#ifdef USE_QUICKPROF
+//#define USE_QUICKPROF 1
+//Don't use quickprof for now, because it contains STL. TODO: replace STL by Bullet container classes.
-#include <iostream>
-#include <fstream>
-#include <string>
-#include <map>
+//if you don't need btClock, you can comment next line
+#define USE_BT_CLOCK 1
+#ifdef USE_BT_CLOCK
#ifdef __PPU__
#include <sys/sys_time.h>
#include <stdio.h>
@@ -43,7 +43,12 @@ typedef uint64_t __int64;
#endif
#if defined(WIN32) || defined(_WIN32)
- #define USE_WINDOWS_TIMERS
+
+ #define USE_WINDOWS_TIMERS
+ #define WIN32_LEAN_AND_MEAN
+ #define NOWINRES
+ #define NOMCX
+ #define NOIME
#include <windows.h>
#include <time.h>
#else
@@ -51,39 +56,12 @@ typedef uint64_t __int64;
#endif
#define mymin(a,b) (a > b ? a : b)
-namespace hidden
-{
- /// A simple data structure representing a single timed block
- /// of code.
- struct ProfileBlock
- {
- ProfileBlock()
- {
- currentBlockStartMicroseconds = 0;
- currentCycleTotalMicroseconds = 0;
- lastCycleTotalMicroseconds = 0;
- totalMicroseconds = 0;
- }
- /// The starting time (in us) of the current block update.
- unsigned long int currentBlockStartMicroseconds;
-
- /// The accumulated time (in us) spent in this block during the
- /// current profiling cycle.
- unsigned long int currentCycleTotalMicroseconds;
-
- /// The accumulated time (in us) spent in this block during the
- /// past profiling cycle.
- unsigned long int lastCycleTotalMicroseconds;
-
- /// The total accumulated time (in us) spent in this block.
- unsigned long int totalMicroseconds;
- };
-
- class Clock
+/// basic clock
+class btClock
{
public:
- Clock()
+ btClock()
{
#ifdef USE_WINDOWS_TIMERS
QueryPerformanceFrequency(&mClockFrequency);
@@ -91,7 +69,7 @@ namespace hidden
reset();
}
- ~Clock()
+ ~btClock()
{
}
@@ -111,14 +89,14 @@ namespace hidden
__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory");
mStartTime = newTime;
#else
- gettimeofday(&mStartTime, NULL);
+ gettimeofday(&mStartTime, 0);
#endif
#endif
}
/// Returns the time in ms since the last call to reset or since
- /// the Clock was created.
+ /// the btClock was created.
unsigned long int getTimeMilliseconds()
{
#ifdef USE_WINDOWS_TIMERS
@@ -168,7 +146,7 @@ namespace hidden
#else
struct timeval currentTime;
- gettimeofday(&currentTime, NULL);
+ gettimeofday(&currentTime, 0);
return (currentTime.tv_sec - mStartTime.tv_sec) * 1000 +
(currentTime.tv_usec - mStartTime.tv_usec) / 1000;
#endif //__PPU__
@@ -226,7 +204,7 @@ namespace hidden
#else
struct timeval currentTime;
- gettimeofday(&currentTime, NULL);
+ gettimeofday(&currentTime, 0);
return (currentTime.tv_sec - mStartTime.tv_sec) * 1000000 +
(currentTime.tv_usec - mStartTime.tv_usec);
#endif//__PPU__
@@ -248,6 +226,50 @@ namespace hidden
#endif //__PPU__
};
+
+#endif //USE_BT_CLOCK
+
+
+#ifdef USE_QUICKPROF
+
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <map>
+
+
+
+
+namespace hidden
+{
+ /// A simple data structure representing a single timed block
+ /// of code.
+ struct ProfileBlock
+ {
+ ProfileBlock()
+ {
+ currentBlockStartMicroseconds = 0;
+ currentCycleTotalMicroseconds = 0;
+ lastCycleTotalMicroseconds = 0;
+ totalMicroseconds = 0;
+ }
+
+ /// The starting time (in us) of the current block update.
+ unsigned long int currentBlockStartMicroseconds;
+
+ /// The accumulated time (in us) spent in this block during the
+ /// current profiling cycle.
+ unsigned long int currentCycleTotalMicroseconds;
+
+ /// The accumulated time (in us) spent in this block during the
+ /// past profiling cycle.
+ unsigned long int lastCycleTotalMicroseconds;
+
+ /// The total accumulated time (in us) spent in this block.
+ unsigned long int totalMicroseconds;
+ };
+
};
/// A static class that manages timing for a set of profiling blocks.
@@ -336,6 +358,7 @@ public:
/// Prints an error message to standard output.
inline static void printError(const std::string& msg)
{
+ //btAssert(0);
std::cout << "[QuickProf error] " << msg << std::endl;
}
@@ -343,7 +366,7 @@ public:
static bool mEnabled;
/// The clock used to time profile blocks.
- static hidden::Clock mClock;
+ static btClock mClock;
/// The starting time (in us) of the current profiling cycle.
static unsigned long int mCurrentCycleStartMicroseconds;