2 #ifndef SYDEVS_TIMER_H_
3 #define SYDEVS_TIMER_H_
10 using clock = std::chrono::steady_clock;
66 , cumulative_dt_(cumulative_dt)
80 return cumulative_dt_;
87 throw std::runtime_error(
"Attempt to start timer that has already been started");
89 start_clk_t_ = clock::now();
95 auto stop_clk_t = clock::now();
97 throw std::runtime_error(
"Attempt to stop timer that has not been started");
99 auto microsecond_count = std::chrono::duration_cast<std::chrono::microseconds>(stop_clk_t - start_clk_t_).count();
101 cumulative_dt_ += interval_dt;
constexpr const quantity fixed_at(scale precision) const
Returns a new quantity value with the length precision changed and fixed.
Definition: quantity.h:610
A class for measuring and accumulating intervals of wallclock time.
Definition: timer.h:25
void start()
Starts the timer.
Definition: timer.h:84
duration stop()
Stops the timer and returns the measured interval of wallclock time.
Definition: timer.h:93
timer & operator=(const timer &)=delete
Copy assignment.
timer(const timer &)=delete
Copy constructor.
bool timing() const
Returns true if the timer has been started but not yet stopped.
Definition: timer.h:72
timer(timer &&)=default
Move constructor.
timer()
Constructs a timer that has not yet accumuated any interval measurements.
Definition: timer.h:56
~timer()=default
Destructor.
duration cumulative_duration() const
Returns the cumulative duration of measured time.
Definition: timer.h:78
timer & operator=(timer &&)=default
Move assignment.
std::chrono::time_point< clock > clock_time
Definition: timer.h:11
std::chrono::steady_clock clock
Definition: timer.h:10
quantity< seconds > duration
Definition: quantity.h:1006
constexpr scale micro
Definition: scale.h:161