diff options
Diffstat (limited to 'compat/timer.hpp')
| -rw-r--r-- | compat/timer.hpp | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/compat/timer.hpp b/compat/timer.hpp index e9efba79..47072226 100644 --- a/compat/timer.hpp +++ b/compat/timer.hpp @@ -9,38 +9,20 @@ #pragma once #include "export.hpp" - -#if defined (_WIN32) -# include <windows.h> -#elif defined(__MACH__) -# include <inttypes.h> -# include <mach/mach_time.h> -#endif - +#include "time.hpp" #include <ctime> -#include <tuple> -class OTR_COMPAT_EXPORT Timer +struct OTR_COMPAT_EXPORT Timer final { - struct timespec state; - long long conv_nsecs(const struct timespec& cur) const; - static void otr_clock_gettime(struct timespec* ts); -#ifdef _WIN32 - static LARGE_INTEGER otr_get_clock_frequency(); -#elif defined(__MACH__) - static mach_timebase_info_data_t otr_get_mach_frequency(); -#endif - - static void wrap_gettime(struct timespec* state); - -public: Timer(); - void start(); - long long elapsed_nsecs() const; - double elapsed_usecs() const; + double elapsed_ms() const; double elapsed_seconds() const; -}; - +private: + struct timespec state {}; + static void gettime(struct timespec* state); + struct timespec get_delta() const; + using ns = time_units::ns; +}; |
