29 #ifndef LBANN_UTILS_TIMER_HPP_INCLUDED 30 #define LBANN_UTILS_TIMER_HPP_INCLUDED 39 using namespace std::chrono;
40 return duration_cast<duration<double>>(steady_clock::now().time_since_epoch())
67 ~
Timer() noexcept = default;
80 void start() noexcept { m_start = ClockType::now(); }
91 auto elapsed_time = this->check();
99 using seconds_type = std::chrono::duration<double>;
100 return running() ? seconds_type(ClockType::now() - m_start).count() : 0.;
118 #endif // LBANN_UTILS_TIMER_HPP_INCLUDED void reset() noexcept
Clear any internal state in the timer.
double check() const noexcept
Get the current elapsed time (seconds) without stopping.
bool running() const noexcept
Check if the timer is running.
double get_time()
Return time in fractional seconds since an epoch.
typename ClockType::time_point TimePoint
Simplifying typedef.
An exceedingly simple duration calculator.
double stop() noexcept
Get the total elapsed time in seconds.
std::chrono::steady_clock ClockType
The clock used for counting.