From d092b050a87b075c43645b34ad00e93b53e24fe2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 May 2018 17:06:39 +0200 Subject: compat/timer: fix big regression --- compat/timer.cpp | 10 +++++----- compat/timer.hpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'compat') diff --git a/compat/timer.cpp b/compat/timer.cpp index 80d2cc1a..0e7fb362 100644 --- a/compat/timer.cpp +++ b/compat/timer.cpp @@ -25,21 +25,21 @@ void Timer::start() // nanoseconds -Timer::time_type Timer::elapsed_nsecs() const +time_type Timer::elapsed_nsecs() const { timespec cur{}; gettime(&cur); return conv_nsecs(cur); } -Timer::time_type Timer::conv_nsecs(const struct timespec& cur) const +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 -time_type Timer::elapsed_usecs() const +double Timer::elapsed_usecs() const { timespec cur{}; gettime(&cur); @@ -49,12 +49,12 @@ time_type Timer::elapsed_usecs() const // milliseconds -time_type Timer::elapsed_ms() const +double Timer::elapsed_ms() const { return elapsed_usecs() / 1000.; } -Timer::time_type Timer::elapsed_seconds() const +double Timer::elapsed_seconds() const { return double(elapsed_nsecs() * 1e-9); } diff --git a/compat/timer.hpp b/compat/timer.hpp index b8b4ae59..fb14145d 100644 --- a/compat/timer.hpp +++ b/compat/timer.hpp @@ -29,9 +29,9 @@ struct OTR_COMPAT_EXPORT Timer final } time_type elapsed_nsecs() const; - time_type elapsed_usecs() const; - time_type elapsed_ms() const; - time_type elapsed_seconds() const; + double elapsed_usecs() const; + double elapsed_ms() const; + double elapsed_seconds() const; private: struct timespec state; static void gettime(struct timespec* state); -- cgit v1.2.3