small update on hierarchical timing integration
This commit is contained in:
@@ -31,7 +31,6 @@
|
|||||||
static GLDebugDrawer gDebugDrawer;
|
static GLDebugDrawer gDebugDrawer;
|
||||||
#include "LinearMath/btQuickProf.h"
|
#include "LinearMath/btQuickProf.h"
|
||||||
|
|
||||||
CProfileIterator * gProfileIterator=0;
|
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -180,16 +179,6 @@ void SimulationLoop()
|
|||||||
void Keyboard(unsigned char key, int x, int y)
|
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)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
gProfileIterator = CProfileManager::Get_Iterator();
|
|
||||||
|
|
||||||
|
|
||||||
int bulletVersion = btGetVersion();
|
int bulletVersion = btGetVersion();
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ m_shootBoxShape(0),
|
|||||||
m_singleStep(false),
|
m_singleStep(false),
|
||||||
m_idle(false)
|
m_idle(false)
|
||||||
{
|
{
|
||||||
|
m_profileIterator = CProfileManager::Get_Iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -79,6 +80,7 @@ m_shootBoxShape(0),
|
|||||||
DemoApplication::~DemoApplication()
|
DemoApplication::~DemoApplication()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
CProfileManager::Release_Iterator(m_profileIterator);
|
||||||
if (m_shootBoxShape)
|
if (m_shootBoxShape)
|
||||||
delete m_shootBoxShape;
|
delete m_shootBoxShape;
|
||||||
|
|
||||||
@@ -242,6 +244,17 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y)
|
|||||||
|
|
||||||
m_lastKey = 0;
|
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)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 'q' : exit(0); break;
|
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)
|
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();
|
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);
|
displayProfileString(xOffset,yStart,blockTime);
|
||||||
yStart += yIncr;
|
yStart += yIncr;
|
||||||
sprintf(blockTime,"press number (1,2...) to display child timings, or 0 to go up to parent" );
|
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;
|
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;
|
accumulated_time += current_total_time;
|
||||||
double fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
|
double fraction = parent_time > SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
|
||||||
|
|
||||||
sprintf(blockTime,"%d -- %s (%.2f %%) :: %.3f ms / frame (%d calls)",
|
sprintf(blockTime,"%d -- %s (%.2f %%) :: %.3f ms / frame (%d calls)",
|
||||||
++i, gProfileIterator->Get_Current_Name(), fraction,
|
++i, m_profileIterator->Get_Current_Name(), fraction,
|
||||||
(current_total_time / (double)frames_since_reset),gProfileIterator->Get_Current_Total_Calls());
|
(current_total_time / (double)frames_since_reset),m_profileIterator->Get_Current_Total_Calls());
|
||||||
displayProfileString(xOffset,yStart,blockTime);
|
displayProfileString(xOffset,yStart,blockTime);
|
||||||
yStart += yIncr;
|
yStart += yIncr;
|
||||||
totalTime += current_total_time;
|
totalTime += current_total_time;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class btTypedConstraint;
|
|||||||
class DemoApplication
|
class DemoApplication
|
||||||
{
|
{
|
||||||
void displayProfileString(int xOffset,int yStart,char* message);
|
void displayProfileString(int xOffset,int yStart,char* message);
|
||||||
|
class CProfileIterator* m_profileIterator;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ unsigned long int btProfiler::mCycleNumber = 0;
|
|||||||
|
|
||||||
static btClock gProfileClock;
|
static btClock gProfileClock;
|
||||||
|
|
||||||
inline void Profile_Get_Ticks(_int64 * ticks)
|
inline void Profile_Get_Ticks(unsigned long int * ticks)
|
||||||
{
|
{
|
||||||
*ticks = gProfileClock.getTimeMicroseconds();
|
*ticks = gProfileClock.getTimeMicroseconds();
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ void CProfileNode::Call( void )
|
|||||||
bool CProfileNode::Return( void )
|
bool CProfileNode::Return( void )
|
||||||
{
|
{
|
||||||
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
||||||
__int64 time;
|
unsigned long int time;
|
||||||
Profile_Get_Ticks(&time);
|
Profile_Get_Ticks(&time);
|
||||||
time-=StartTime;
|
time-=StartTime;
|
||||||
TotalTime += (float)time / Profile_Get_Tick_Rate();
|
TotalTime += (float)time / Profile_Get_Tick_Rate();
|
||||||
@@ -224,7 +224,7 @@ void CProfileIterator::Enter_Parent( void )
|
|||||||
CProfileNode CProfileManager::Root( "Root", NULL );
|
CProfileNode CProfileManager::Root( "Root", NULL );
|
||||||
CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root;
|
CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root;
|
||||||
int CProfileManager::FrameCounter = 0;
|
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 )
|
float CProfileManager::Get_Time_Since_Reset( void )
|
||||||
{
|
{
|
||||||
__int64 time;
|
unsigned long int time;
|
||||||
Profile_Get_Ticks(&time);
|
Profile_Get_Ticks(&time);
|
||||||
time -= ResetTime;
|
time -= ResetTime;
|
||||||
return (float)time / Profile_Get_Tick_Rate();
|
return (float)time / Profile_Get_Tick_Rate();
|
||||||
|
|||||||
@@ -746,7 +746,7 @@ protected:
|
|||||||
const char * Name;
|
const char * Name;
|
||||||
int TotalCalls;
|
int TotalCalls;
|
||||||
float TotalTime;
|
float TotalTime;
|
||||||
__int64 StartTime;
|
unsigned long int StartTime;
|
||||||
int RecursionCounter;
|
int RecursionCounter;
|
||||||
|
|
||||||
CProfileNode * Parent;
|
CProfileNode * Parent;
|
||||||
@@ -810,7 +810,7 @@ private:
|
|||||||
static CProfileNode Root;
|
static CProfileNode Root;
|
||||||
static CProfileNode * CurrentNode;
|
static CProfileNode * CurrentNode;
|
||||||
static int FrameCounter;
|
static int FrameCounter;
|
||||||
static __int64 ResetTime;
|
static unsigned long int ResetTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user