30namespace triqs::utility {
42 using clock_t = std::chrono::high_resolution_clock;
45 clock_t::time_point start_time;
46 clock_t::duration total_time = clock_t::duration(0);
53 start_time = clock_t::now();
58 total_time += clock_t::now() - start_time;
64 total_time = clock_t::duration(0);
72 [[nodiscard]]
bool is_running()
const {
return running; }
78 operator double()
const {
79 std::chrono::duration<double> total_time_seconds(total_time);
80 if (
is_running()) total_time_seconds += clock_t::now() - start_time;
81 return total_time_seconds.count();
Accumulating wall-clock timer based on std::chrono::high_resolution_clock.
void stop()
Stop the timer and add the elapsed interval to the running total.
std::chrono::high_resolution_clock clock_t
Underlying clock type.
void reset()
Reset the accumulated time to zero and put the timer in the stopped state.
void start()
Start (or resume) the timer.
bool is_running() const
Whether the timer is currently running.