18 #ifndef ION_PORT_TIMER_H_
19 #define ION_PORT_TIMER_H_
22 #include <type_traits>
24 #include "base/integral_types.h"
31 #if defined(ION_PLATFORM_WINDOWS)
36 typedef std::nano period;
37 typedef std::chrono::duration<rep, period> duration;
38 typedef std::chrono::time_point<steady_clock> time_point;
39 static const bool is_steady =
true;
41 static time_point now();
45 typedef std::conditional<std::chrono::high_resolution_clock::is_steady,
48 std::chrono::high_resolution_clock,
60 Clock::duration
Get()
const;
77 steady_clock::time_point start_;
83 #endif // ION_PORT_TIMER_H_
double GetInS() const
Returns the elapsed time since construction or the last Reset() in seconds.
double GetInMs() const
Returns the elapsed time since construction or the last Reset() in milliseconds.
static void SleepNSeconds(unsigned int seconds)
Sleeps for the passed number of seconds.
static void SleepNMilliseconds(unsigned int milliseconds)
Sleeps for n milliseconds.
std::conditional< std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock, std::chrono::steady_clock >::type steady_clock
Use the high_resolution_clock if it is steady, otherwise use the steady_clock.
void Reset()
Resets the timer.
Clock::duration Get() const
Returns the elapsed time since construction or the last Reset().