15 #ifndef BT_QUICK_PROF_H 16 #define BT_QUICK_PROF_H 19 #define USE_BT_CLOCK 1 57 #define BT_NO_PROFILE 1 76 CProfileNode(
const char * name, CProfileNode * parent );
77 ~CProfileNode(
void );
79 CProfileNode * Get_Sub_Node(
const char * name );
81 CProfileNode * Get_Parent(
void ) {
return Parent; }
82 CProfileNode * Get_Sibling(
void ) {
return Sibling; }
83 CProfileNode * Get_Child(
void ) {
return Child; }
90 const char * Get_Name(
void ) {
return Name; }
91 int Get_Total_Calls(
void ) {
return TotalCalls; }
92 float Get_Total_Time(
void ) {
return TotalTime; }
93 void* GetUserPointer()
const {
return m_userPtr;}
94 void SetUserPointer(
void* ptr) { m_userPtr = ptr;}
100 unsigned long int StartTime;
101 int RecursionCounter;
103 CProfileNode * Parent;
104 CProfileNode * Child;
105 CProfileNode * Sibling;
110 class CProfileIterator
117 bool Is_Root(
void) {
return (CurrentParent->Get_Parent() == 0); }
119 void Enter_Child(
int index );
120 void Enter_Largest_Child(
void );
121 void Enter_Parent(
void );
124 const char * Get_Current_Name(
void ) {
return CurrentChild->Get_Name(); }
125 int Get_Current_Total_Calls(
void ) {
return CurrentChild->Get_Total_Calls(); }
126 float Get_Current_Total_Time(
void ) {
return CurrentChild->Get_Total_Time(); }
128 void* Get_Current_UserPointer(
void ) {
return CurrentChild->GetUserPointer(); }
129 void Set_Current_UserPointer(
void* ptr) {CurrentChild->SetUserPointer(ptr);}
131 const char * Get_Current_Parent_Name(
void ) {
return CurrentParent->Get_Name(); }
132 int Get_Current_Parent_Total_Calls(
void ) {
return CurrentParent->Get_Total_Calls(); }
133 float Get_Current_Parent_Total_Time(
void ) {
return CurrentParent->Get_Total_Time(); }
139 CProfileNode * CurrentParent;
140 CProfileNode * CurrentChild;
143 CProfileIterator( CProfileNode * start );
144 friend class CProfileManager;
149 class CProfileManager {
151 static void Start_Profile(
const char * name );
152 static void Stop_Profile(
void );
154 static void CleanupMemory(
void)
156 Root.CleanupMemory();
159 static void Reset(
void );
160 static void Increment_Frame_Counter(
void );
161 static int Get_Frame_Count_Since_Reset(
void ) {
return FrameCounter; }
162 static float Get_Time_Since_Reset(
void );
164 static CProfileIterator * Get_Iterator(
void )
167 return new CProfileIterator( &Root );
169 static void Release_Iterator( CProfileIterator * iterator ) {
delete ( iterator); }
171 static void dumpRecursive(CProfileIterator* profileIterator,
int spacing);
173 static void dumpAll();
176 static CProfileNode Root;
177 static CProfileNode * CurrentNode;
178 static int FrameCounter;
179 static unsigned long int ResetTime;
185 class CProfileSample {
187 CProfileSample(
const char * name )
189 CProfileManager::Start_Profile( name );
192 ~CProfileSample(
void )
194 CProfileManager::Stop_Profile();
199 #define BT_PROFILE( name ) CProfileSample __profile( name ) 203 #define BT_PROFILE( name ) 205 #endif //#ifndef BT_NO_PROFILE 209 #endif //BT_QUICK_PROF_H btScalar getTimeSeconds()
Returns the time in s since the last call to reset or since the Clock was created.
unsigned long int getTimeMicroseconds()
Returns the time in us since the last call to reset or since the Clock was created.
The btClock is a portable basic clock that measures accurate time in seconds, use for profiling...
void reset()
Resets the initial reference time.
unsigned long int getTimeMilliseconds()
Returns the time in ms since the last call to reset or since the btClock was created.
btClock()
The btClock is a portable basic clock that measures accurate time in seconds, use for profiling...
struct btClockData * m_data
btClock & operator=(const btClock &other)
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...