1 #include <mach/mach_time.h>
5 double intervalInCycles( uint64_t startTime
, uint64_t endTime
)
7 uint64_t rawTime
= endTime
- startTime
;
8 static double conversion
= 0.0;
10 if( 0.0 == conversion
)
12 mach_timebase_info_data_t info
;
13 kern_return_t err
= mach_timebase_info( &info
);
18 size_t freqSize
= sizeof( freq
);
19 int err2
= sysctlbyname( "hw.cpufrequency", &freq
, &freqSize
, NULL
, 0L );
23 conversion
= (double) freq
* (1e-9 * (double) info
.numer
/ (double) info
.denom
);
26 return (double) rawTime
* conversion
;