diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-05-17 12:25:24 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-05-17 12:25:24 +0200 |
commit | e17cc16b100031672b3dbb0a4f74e198c20d091a (patch) | |
tree | 70dc5429a07367af117c45df4d129af8f2eb14a5 /compat/timer.cpp | |
parent | 5a8820764f3d539a4269d907e7977c45afe7bdab (diff) |
compat/timer: use time_t
Diffstat (limited to 'compat/timer.cpp')
-rw-r--r-- | compat/timer.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compat/timer.cpp b/compat/timer.cpp index 162ba16f..ef139d74 100644 --- a/compat/timer.cpp +++ b/compat/timer.cpp @@ -11,6 +11,8 @@ #include "timer.hpp" #include <cmath> +using time_type = Timer::time_type; + Timer::Timer() { start(); @@ -23,21 +25,21 @@ void Timer::start() // nanoseconds -long long Timer::elapsed_nsecs() const +Timer::time_type Timer::elapsed_nsecs() const { timespec cur{}; gettime(&cur); return conv_nsecs(cur); } -long long Timer::conv_nsecs(const struct timespec& cur) const +Timer::time_type Timer::conv_nsecs(const struct timespec& cur) const { return (cur.tv_sec - state.tv_sec) * 1000000000LL + (cur.tv_nsec - state.tv_nsec); } // microseconds -double Timer::elapsed_usecs() const +time_type Timer::elapsed_usecs() const { timespec cur{}; gettime(&cur); @@ -47,12 +49,12 @@ double Timer::elapsed_usecs() const // milliseconds -double Timer::elapsed_ms() const +time_type Timer::elapsed_ms() const { return elapsed_usecs() / 1000.; } -double Timer::elapsed_seconds() const +Timer::time_type Timer::elapsed_seconds() const { return double(elapsed_nsecs() * 1e-9L); } @@ -77,7 +79,6 @@ static void otr_clock_gettime(timespec* ts) static const LARGE_INTEGER freq = otr_get_clock_frequency(); LARGE_INTEGER d; - (void) QueryPerformanceCounter(&d); using ll = long long; |