Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
OOProfilingStopwatch.h File Reference
import "OOCocoa.h"
import "OOFunctionAttributes.h"
import "OOTypes.h"
import <mach/mach_time.h>
+ Include dependency graph for OOProfilingStopwatch.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  OOProfilingStopwatch
 

Macros

#define OO_PROFILING_STOPWATCH_MACH_ABSOLUTE_TIME   1
 
#define OOGetHighResTime   mach_absolute_time
 
#define OODisposeHighResTime(time)   do { (void)time; } while (0)
 
#define OOCopyHighResTime(time)   ((OOHighResTimeValue)time)
 

Typedefs

typedef uint64_t OOHighResTimeValue
 

Functions

OOTimeDelta OOHighResTimeDeltaInSeconds (OOHighResTimeValue startTime, OOHighResTimeValue endTime)
 

Macro Definition Documentation

◆ OO_PROFILING_STOPWATCH_MACH_ABSOLUTE_TIME

#define OO_PROFILING_STOPWATCH_MACH_ABSOLUTE_TIME   1

Definition at line 52 of file OOProfilingStopwatch.h.

◆ OOCopyHighResTime

#define OOCopyHighResTime ( time)    ((OOHighResTimeValue)time)

Definition at line 59 of file OOProfilingStopwatch.h.

◆ OODisposeHighResTime

#define OODisposeHighResTime ( time)    do { (void)time; } while (0)

◆ OOGetHighResTime

#define OOGetHighResTime   mach_absolute_time

Typedef Documentation

◆ OOHighResTimeValue

typedef uint64_t OOHighResTimeValue

Definition at line 55 of file OOProfilingStopwatch.h.

Function Documentation

◆ OOHighResTimeDeltaInSeconds()

OOTimeDelta OOHighResTimeDeltaInSeconds ( OOHighResTimeValue startTime,
OOHighResTimeValue endTime )

Definition at line 115 of file OOProfilingStopwatch.m.

116{
117#if OO_PROFILING_STOPWATCH_MACH_ABSOLUTE_TIME
118 uint64_t diff = endTime - startTime;
119 static double conversion = 0.0;
120
121 if (EXPECT_NOT(conversion == 0.0))
122 {
123 mach_timebase_info_data_t info;
124 kern_return_t err = mach_timebase_info(&info);
125
126 if (err == 0)
127 {
128 conversion = 1e-9 * (double)info.numer / (double)info.denom;
129 }
130 }
131
132 return conversion * (double)diff;
133#elif OO_PROFILING_STOPWATCH_WINDOWS
134 return 1e-3 * (double)(endTime - startTime);
135#elif OO_PROFILING_STOPWATCH_GETTIMEOFDAY
136 int_fast32_t deltaS = (int_fast32_t)endTime.tv_sec - (int_fast32_t)startTime.tv_sec;
137 int_fast32_t deltaU = (int_fast32_t)endTime.tv_usec - (int_fast32_t)startTime.tv_usec;
138 double result = deltaU;
139 result = (result * 1e-6) + deltaS;
140 return result;
141#elif OO_PROFILING_STOPWATCH_JS_NOW
142 return 1e-6 * (double)(endTime - startTime);
143#endif
144}
#define EXPECT_NOT(x)

Referenced by OOJSResumeTimeLimiter(), and OperationCallback().

+ Here is the caller graph for this function: