clock_gettime(MONOTONIC) seems more appropriate than gettimeofday for our purposes.

Reluctant to do this before 1.0 though so I'll leave it as a pull request for now.
This commit is contained in:
Henrik Rydgard 2015-01-31 11:35:53 +01:00
parent 1467753c35
commit 044cc8e950

View File

@ -60,8 +60,10 @@ double real_time_now() {
return (double)diff / (double)_frequency;
}
#endif
struct timespec time;
clock_gettime(CLOCK_MONOTONIC_RAW, &time);
return time.tv_sec + time.tv_nsec / 1.0e9;
#else
static time_t start;
struct timeval tv;
gettimeofday(&tv, NULL);
@ -70,6 +72,7 @@ double real_time_now() {
}
tv.tv_sec -= start;
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
#endif
}
#endif