Make clock_gettime() faster on FreeBSD

This commit is contained in:
Justine Tunney 2022-06-11 00:05:06 -07:00
parent 5deda43766
commit 5ea618f0af
15 changed files with 67 additions and 18 deletions

View file

@ -40,10 +40,10 @@ static long double GetTimeSample(void) {
uint64_t tick1, tick2;
long double time1, time2;
sched_yield();
time1 = dtime(CLOCK_REALTIME);
time1 = dtime(CLOCK_MONOTONIC);
tick1 = rdtsc();
nanosleep(&(struct timespec){0, 1000000}, NULL);
time2 = dtime(CLOCK_REALTIME);
time2 = dtime(CLOCK_MONOTONIC);
tick2 = rdtsc();
return (time2 - time1) * 1e9 / MAX(1, tick2 - tick1);
}