Avoid a division in time_now_d(). Minor optimizations.

This commit is contained in:
Henrik Rydgård committed 2020-10-10 19:05:46 +02:00
1 parent 1e923d52f3
commit e97baa503a
4 files changed
+8 -8

No files matched your search

+2 -6
View File
@@ -42,18 +42,14 @@ double time_now_d() {
#else
static uint64_t _frequency = 0;
static uint64_t _starttime = 0;
double time_now_d() {
static time_t start;
struct timeval tv;
gettimeofday(&tv, NULL);
gettimeofday(&tv, nullptr);
if (start == 0) {
start = tv.tv_sec;
}
tv.tv_sec -= start;
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
return (double)(tv.tv_sec - start) + (double)tv.tv_usec * (1.0 / 1000000.0);
}
#endif