From 0da5790e5c3ec4da0d7f046ba438189ca87a20d1 Mon Sep 17 00:00:00 2001 From: ejcoumans Date: Wed, 21 Nov 2007 03:49:23 +0000 Subject: [PATCH] small update on hierarchical timing integration --- Demos/AllBulletDemos/Main.cpp | 12 ------------ Demos/OpenGL/DemoApplication.cpp | 29 +++++++++++++++++++++-------- Demos/OpenGL/DemoApplication.h | 1 + src/LinearMath/btQuickprof.cpp | 8 ++++---- src/LinearMath/btQuickprof.h | 4 ++-- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Demos/AllBulletDemos/Main.cpp b/Demos/AllBulletDemos/Main.cpp index dfccb0992..378b1cd79 100644 --- a/Demos/AllBulletDemos/Main.cpp +++ b/Demos/AllBulletDemos/Main.cpp @@ -31,7 +31,6 @@ static GLDebugDrawer gDebugDrawer; #include "LinearMath/btQuickProf.h" -CProfileIterator * gProfileIterator=0; namespace @@ -180,16 +179,6 @@ void SimulationLoop() void Keyboard(unsigned char key, int x, int y) { - if (key >= 0x31 && key < 0x37) - { - int child = key-0x31; - gProfileIterator->Enter_Child(child); - } - if (key==0x30) - { - gProfileIterator->Enter_Parent(); - return; - } @@ -239,7 +228,6 @@ void MouseMotion(int x, int y) int main(int argc, char** argv) { - gProfileIterator = CProfileManager::Get_Iterator(); int bulletVersion = btGetVersion(); diff --git a/Demos/OpenGL/DemoApplication.cpp b/Demos/OpenGL/DemoApplication.cpp index 18c6deab3..923689d4d 100644 --- a/Demos/OpenGL/DemoApplication.cpp +++ b/Demos/OpenGL/DemoApplication.cpp @@ -72,6 +72,7 @@ m_shootBoxShape(0), m_singleStep(false), m_idle(false) { + m_profileIterator = CProfileManager::Get_Iterator(); } @@ -79,6 +80,7 @@ m_shootBoxShape(0), DemoApplication::~DemoApplication() { + CProfileManager::Release_Iterator(m_profileIterator); if (m_shootBoxShape) delete m_shootBoxShape; @@ -242,6 +244,17 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y) m_lastKey = 0; + if (key >= 0x31 && key < 0x37) + { + int child = key-0x31; + m_profileIterator->Enter_Child(child); + } + if (key==0x30) + { + m_profileIterator->Enter_Parent(); + } + + switch (key) { case 'q' : exit(0); break; @@ -760,7 +773,7 @@ void DemoApplication::resetPerspectiveProjection() -extern CProfileIterator * gProfileIterator; +extern CProfileIterator * m_profileIterator; void DemoApplication::displayProfileString(int xOffset,int yStart,char* message) { @@ -788,12 +801,12 @@ void DemoApplication::showProfileInfo(float& xOffset,float& yStart, float yIncr) int frames_since_reset = CProfileManager::Get_Frame_Count_Since_Reset(); - gProfileIterator->First(); + m_profileIterator->First(); - double parent_time = gProfileIterator->Is_Root() ? time_since_reset : gProfileIterator->Get_Current_Parent_Total_Time(); + double parent_time = m_profileIterator->Is_Root() ? time_since_reset : m_profileIterator->Get_Current_Parent_Total_Time(); { - sprintf(blockTime,"--- Profiling: %s (total running time: %.3f m) ---", gProfileIterator->Get_Current_Parent_Name(), parent_time ); + sprintf(blockTime,"--- Profiling: %s (total running time: %.3f m) ---", m_profileIterator->Get_Current_Parent_Name(), parent_time ); displayProfileString(xOffset,yStart,blockTime); yStart += yIncr; sprintf(blockTime,"press number (1,2...) to display child timings, or 0 to go up to parent" ); @@ -805,15 +818,15 @@ void DemoApplication::showProfileInfo(float& xOffset,float& yStart, float yIncr) double accumulated_time = 0.f; - for (int i = 0; !gProfileIterator->Is_Done(); gProfileIterator->Next()) + for (int i = 0; !m_profileIterator->Is_Done(); m_profileIterator->Next()) { - double current_total_time = gProfileIterator->Get_Current_Total_Time(); + double current_total_time = m_profileIterator->Get_Current_Total_Time(); accumulated_time += current_total_time; double fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f; sprintf(blockTime,"%d -- %s (%.2f %%) :: %.3f ms / frame (%d calls)", - ++i, gProfileIterator->Get_Current_Name(), fraction, - (current_total_time / (double)frames_since_reset),gProfileIterator->Get_Current_Total_Calls()); + ++i, m_profileIterator->Get_Current_Name(), fraction, + (current_total_time / (double)frames_since_reset),m_profileIterator->Get_Current_Total_Calls()); displayProfileString(xOffset,yStart,blockTime); yStart += yIncr; totalTime += current_total_time; diff --git a/Demos/OpenGL/DemoApplication.h b/Demos/OpenGL/DemoApplication.h index c690913ae..bd5f6e673 100644 --- a/Demos/OpenGL/DemoApplication.h +++ b/Demos/OpenGL/DemoApplication.h @@ -52,6 +52,7 @@ class btTypedConstraint; class DemoApplication { void displayProfileString(int xOffset,int yStart,char* message); + class CProfileIterator* m_profileIterator; protected: diff --git a/src/LinearMath/btQuickprof.cpp b/src/LinearMath/btQuickprof.cpp index 6d10ebc9f..cc69888f8 100644 --- a/src/LinearMath/btQuickprof.cpp +++ b/src/LinearMath/btQuickprof.cpp @@ -50,7 +50,7 @@ unsigned long int btProfiler::mCycleNumber = 0; static btClock gProfileClock; -inline void Profile_Get_Ticks(_int64 * ticks) +inline void Profile_Get_Ticks(unsigned long int * ticks) { *ticks = gProfileClock.getTimeMicroseconds(); } @@ -152,7 +152,7 @@ void CProfileNode::Call( void ) bool CProfileNode::Return( void ) { if ( --RecursionCounter == 0 && TotalCalls != 0 ) { - __int64 time; + unsigned long int time; Profile_Get_Ticks(&time); time-=StartTime; TotalTime += (float)time / Profile_Get_Tick_Rate(); @@ -224,7 +224,7 @@ void CProfileIterator::Enter_Parent( void ) CProfileNode CProfileManager::Root( "Root", NULL ); CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root; int CProfileManager::FrameCounter = 0; -__int64 CProfileManager::ResetTime = 0; +unsigned long int CProfileManager::ResetTime = 0; /*********************************************************************************************** @@ -291,7 +291,7 @@ void CProfileManager::Increment_Frame_Counter( void ) *=============================================================================================*/ float CProfileManager::Get_Time_Since_Reset( void ) { - __int64 time; + unsigned long int time; Profile_Get_Ticks(&time); time -= ResetTime; return (float)time / Profile_Get_Tick_Rate(); diff --git a/src/LinearMath/btQuickprof.h b/src/LinearMath/btQuickprof.h index 9b0289e88..1476c4777 100644 --- a/src/LinearMath/btQuickprof.h +++ b/src/LinearMath/btQuickprof.h @@ -746,7 +746,7 @@ protected: const char * Name; int TotalCalls; float TotalTime; - __int64 StartTime; + unsigned long int StartTime; int RecursionCounter; CProfileNode * Parent; @@ -810,7 +810,7 @@ private: static CProfileNode Root; static CProfileNode * CurrentNode; static int FrameCounter; - static __int64 ResetTime; + static unsigned long int ResetTime; };