29 typedef typename clock::duration duration;
30 typedef typename clock::time_point time_point;
59 [[nodiscard]] duration
elapsed()
const;
61 [[nodiscard]] std::chrono::duration<double>::rep
seconds()
const;
68 [[nodiscard]] time_point
now()
const {
return clock::now(); }
77TimerBase<T> &TimerBase<T>::operator+=(
const TimerBase<T> &other) {
78 elapsed_ += other.elapsed();
83TimerBase<T> TimerBase<T>::operator+(
const TimerBase<T> &other)
const {
84 TimerBase<T> result = *
this;
90using chosen_steady_clock = std::conditional<std::chrono::high_resolution_clock::is_steady,
91 std::chrono::high_resolution_clock, std::chrono::steady_clock>::type;
93extern template class TimerBase<chosen_steady_clock>;
99 typedef std::micro period;
100 typedef std::chrono::duration<rep, period> duration;
101 typedef std::chrono::time_point<user_clock> time_point;
102 const bool is_steady =
false;
103 static time_point now();
162 const bool enabled_{
false};
Simple timer class to evaluate the performance of the software.
TimerBase()
Construct a new TimerBase object.
duration elapsed_
Elapsed time so far. This doesn't include the current fragment if it is running.
duration elapsed() const
Get read-only access to the duration of elapsed time of the timer.
time_point last_start_
Last time_point when the timer is started or resumed.
bool is_running() const
Check whether the timer is running.
void Resume()
Resume the timer.
time_point now() const
Get read-only access to the current instant of the timer.
void Start()
Start the timer.
void Pause()
Pause the timer.
bool running_
Whether the timer is running or not.
std::chrono::duration< double >::rep seconds() const
Get read-only access to the number elapsed seconds of the timer.
The TimeGuard wraps a timer object and pauses it when the guard object is destructed.
Timer *const timer_
The timer to be guarded.
Timer class using the a steady clock.
Timer class using the user_clock.
Global namespace for the dlinear library.