63 #ifndef prof_lean_timer_h 64 #define prof_lean_timer_h 69 # define _POSIX_SOURCE 83 #if defined(__cplusplus) 91 inline static uint64_t
94 static const uint64_t microsecPerSec = 1000000;
95 return (x * microsecPerSec);
99 inline static uint64_t
102 static const uint64_t nanosecPerMicrosec = 1000;
103 return (x / nanosecPerMicrosec);
113 long ret = clock_gettime(clockid, &ts);
136 #ifdef CLOCK_REALTIME_HR 154 inline static uint64_t
159 #if defined(__x86_64__) 162 asm volatile (
"rdtsc" :
"=a" (lo),
"=d" (hi));
163 tsc = (((uint64_t)hi) << 32) | ((uint64_t)lo);
165 #elif defined(__i386__) 167 asm volatile (
".byte 0x0f, 0x31" :
"=A" (tsc));
169 #elif defined(__powerpc64__) 171 asm volatile (
"mftb %0" :
"=r" (tsc) : );
173 #elif defined(__powerpc__) 175 uint32_t hi, lo,
tmp;
182 :
"=r" (hi),
"=r" (lo),
"=r" (
tmp));
183 tsc = (((uint64_t)hi) << 32) | ((uint64_t)lo);
186 # warning "lib/support-lean/timer.h: time_getTSC()" 195 #if defined(__cplusplus)
static uint64_t time_cvtNanosecToMicrosecs(uint64_t x)
static uint64_t time_getTSC()
static uint64_t time_cvtSecToMicrosecs(uint64_t x)
static int time_getTimeCPU(uint64_t *time)
static int time_getTime_us(clockid_t clockid, uint64_t *time)
static int time_getTimeReal(uint64_t *time)