18 using clock_used = std::chrono::high_resolution_clock;
19 using duration_unit = std::chrono::seconds;
24 std::chrono::time_point<clock_used> m_start_time;
25 std::chrono::time_point<clock_used> m_end_time;
26 bool m_is_running{
false};
30 WallclockTimer::~WallclockTimer() =
default;
32 void WallclockTimer::start()
34 m_state->m_is_running =
true;
35 m_state->m_start_time = clock_used::now();
38 void WallclockTimer::stop()
40 m_state->m_is_running =
false;
41 m_state->m_end_time = clock_used::now();
48 ? std::chrono::duration_cast<duration_unit>(clock_used::now() - m_state->m_start_time)
49 : std::chrono::duration_cast<duration_unit>(m_state->m_end_time
50 - m_state->m_start_time);
52 return (
double)diff.count();
Defines WallclockTimer class.
double runTime() const
returns run time in sec.
Internal state of a WallclockTimer object.