25 #include <sys/sys_time.h>
26 #include <sys/time_util.h>
30 #if defined (SUNOS) || defined (__SUNOS__)
34 #if defined(WIN32) || defined(_WIN32)
36 #define BT_USE_WINDOWS_TIMERS
37 #define WIN32_LEAN_AND_MEAN
55 #define mymin(a,b) (a > b ? a : b)
60 #ifdef BT_USE_WINDOWS_TIMERS
71 #endif //__CELLOS_LV2__
79 #ifdef BT_USE_WINDOWS_TIMERS
106 #ifdef BT_USE_WINDOWS_TIMERS
111 #ifdef __CELLOS_LV2__
116 SYS_TIMEBASE_GET( newTime );
128 #ifdef BT_USE_WINDOWS_TIMERS
129 LARGE_INTEGER currentTime;
130 QueryPerformanceCounter(¤tTime);
131 LONGLONG elapsedTime = currentTime.QuadPart -
134 unsigned long msecTicks = (
unsigned long)(1000 * elapsedTime /
140 signed long msecOff = (
signed long)(msecTicks - elapsedTicks);
141 if (msecOff < -100 || msecOff > 100)
144 LONGLONG msecAdjustment =
mymin(msecOff *
148 elapsedTime -= msecAdjustment;
151 msecTicks = (
unsigned long)(1000 * elapsedTime /
161 #ifdef __CELLOS_LV2__
162 uint64_t freq=sys_time_get_timebase_frequency();
163 double dFreq=((double) freq) / 1000.0;
166 SYS_TIMEBASE_GET( newTime );
172 struct timeval currentTime;
173 gettimeofday(¤tTime, 0);
176 #endif //__CELLOS_LV2__
184 #ifdef BT_USE_WINDOWS_TIMERS
185 LARGE_INTEGER currentTime;
186 QueryPerformanceCounter(¤tTime);
187 LONGLONG elapsedTime = currentTime.QuadPart -
191 unsigned long msecTicks = (
unsigned long)(1000 * elapsedTime /
198 signed long msecOff = (
signed long)(msecTicks - elapsedTicks);
199 if (msecOff < -100 || msecOff > 100)
202 LONGLONG msecAdjustment =
mymin(msecOff *
206 elapsedTime -= msecAdjustment;
213 unsigned long usecTicks = (
unsigned long)(1000000 * elapsedTime /
219 #ifdef __CELLOS_LV2__
220 uint64_t freq=sys_time_get_timebase_frequency();
221 double dFreq=((double) freq)/ 1000000.0;
225 SYS_TIMEBASE_GET( newTime );
230 struct timeval currentTime;
231 gettimeofday(¤tTime, 0);
234 #endif//__CELLOS_LV2__
276 RecursionCounter( 0 ),
314 if ( child->
Name == name ) {
356 unsigned long int time;
474 gProfileClock.
reset();
496 unsigned long int time;
506 profileIterator->
First();
507 if (profileIterator->
Is_Done())
513 for (i=0;i<spacing;i++) printf(
".");
514 printf(
"----------------------------------\n");
515 for (i=0;i<spacing;i++) printf(
".");
516 printf(
"Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->
Get_Current_Parent_Name(), parent_time );
517 float totalTime = 0.f;
522 for (i = 0; !profileIterator->
Is_Done(); i++,profileIterator->
Next())
526 accumulated_time += current_total_time;
527 float fraction = parent_time >
SIMD_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
529 int i;
for (i=0;i<spacing;i++) printf(
".");
531 printf(
"%d -- %s (%.2f %%) :: %.3f ms / frame (%d calls)\n",i, profileIterator->
Get_Current_Name(), fraction,(current_total_time / (double)frames_since_reset),profileIterator->
Get_Current_Total_Calls());
532 totalTime += current_total_time;
536 if (parent_time < accumulated_time)
538 printf(
"what's wrong\n");
540 for (i=0;i<spacing;i++) printf(
".");
541 printf(
"%s (%.3f %%) :: %.3f ms\n",
"Unaccounted:",parent_time >
SIMD_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
543 for (i=0;i<numChildren;i++)
566 #endif //BT_NO_PROFILE
CProfileNode * Get_Sub_Node(const char *name)
static CProfileNode * CurrentNode
CProfileNode * Get_Child(void)
CProfileIterator(CProfileNode *start)
static void Start_Profile(const char *name)
CProfileNode * CurrentParent
LONGLONG mPrevElapsedTime
const char * Get_Current_Name(void)
float Get_Current_Parent_Total_Time(void)
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...
float Get_Current_Total_Time(void)
void Enter_Child(int index)
void reset()
Resets the initial reference time.
An iterator to navigate through the tree.
static void Stop_Profile(void)
float Profile_Get_Tick_Rate(void)
unsigned long int getTimeMilliseconds()
Returns the time in ms since the last call to reset or since the btClock was created.
static void dumpRecursive(CProfileIterator *profileIterator, int spacing)
static unsigned long int ResetTime
btClock()
The btClock is a portable basic clock that measures accurate time in seconds, use for profiling...
CProfileNode * Get_Sibling(void)
struct btClockData * m_data
void Profile_Get_Ticks(unsigned long int *ticks)
static void Release_Iterator(CProfileIterator *iterator)
btClock & operator=(const btClock &other)
static btClock gProfileClock
static float Get_Time_Since_Reset(void)
A node in the Profile Hierarchy Tree.
static void Increment_Frame_Counter(void)
CProfileNode * Get_Parent(void)
int Get_Current_Total_Calls(void)
const char * Get_Name(void)
CProfileNode * CurrentChild
unsigned long int StartTime
CProfileNode(const char *name, CProfileNode *parent)
LARGE_INTEGER mClockFrequency
static CProfileIterator * Get_Iterator(void)
static int Get_Frame_Count_Since_Reset(void)
const char * Get_Current_Parent_Name(void)