27 #ifndef CLASSES_TIMER_H_
28 #define CLASSES_TIMER_H_
42 template<
typename T = std::chrono::duration<
double>,
43 typename CLOCK_T = std::chrono::steady_clock>
55 _start{CLOCK_T::now()}, _end{_start}
66 _start = _end = CLOCK_T::now();
78 _end = CLOCK_T::now();
88 double tics() const noexcept
90 return std::chrono::duration_cast<T>(_end -
_start).count();
102 template<
typename U = T>
105 return std::chrono::duration_cast<U>(_end -
_start);
131 virtual ~Timer() =
default;
142 std::ostream&
display(std::ostream& os)
const override
CLOCK_T::time_point _start
Definition: timer.h:47
std::ostream & display(std::ostream &os) const override
qpp::IDisplay::display() override
Definition: timer.h:142
Quantum++ main namespace.
Definition: codes.h:30
Chronometer.
Definition: timer.h:44
Timer() noexcept
Constructs an instance with the current time as the starting point.
Definition: timer.h:54
Timer & operator=(const Timer &)=default
Default copy assignment operator.
Abstract class (interface) that mandates the definition of virtual std::ostream& display(std::ostream...
Definition: idisplay.h:43
CLOCK_T::time_point _end
Definition: timer.h:47
virtual ~Timer()=default
Default virtual destructor.
double tics() const noexcept
Time passed in the duration specified by T.
Definition: timer.h:88
void tic() noexcept
Resets the chronometer.
Definition: timer.h:64
U get_duration() const noexcept
Duration specified by U.
Definition: timer.h:103
const Timer & toc() noexcept
Stops the chronometer.
Definition: timer.h:76