32 #ifndef CLASSES_TIMER_H_ 33 #define CLASSES_TIMER_H_ 45 template <
typename T = std::chrono::duration<
double>,
46 typename CLOCK_T = std::chrono::steady_clock>
56 Timer() noexcept : start_{CLOCK_T::now()}, end_{start_} {}
63 void tic() noexcept { start_ = end_ = CLOCK_T::now(); }
73 end_ = CLOCK_T::now();
83 double tics() const noexcept {
84 return std::chrono::duration_cast<T>(end_ -
start_).count();
96 template <
typename U = T>
98 return std::chrono::duration_cast<U>(end_ -
start_);
124 virtual ~Timer() =
default;
135 std::ostream&
display(std::ostream& os)
const override {
CLOCK_T::time_point end_
Definition: timer.h:49
std::ostream & display(std::ostream &os) const override
qpp::IDisplay::display() override
Definition: timer.h:135
Quantum++ main namespace.
Definition: codes.h:35
Chronometer.
Definition: timer.h:47
Timer() noexcept
Constructs an instance with the current time as the starting point.
Definition: timer.h:56
Timer & operator=(const Timer &)=default
Default copy assignment operator.
CLOCK_T::time_point start_
Definition: timer.h:49
Abstract class (interface) that mandates the definition of virtual std::ostream& display(std::ostream...
Definition: idisplay.h:46
virtual ~Timer()=default
Default virtual destructor.
double tics() const noexcept
Time passed in the duration specified by T.
Definition: timer.h:83
void tic() noexcept
Resets the chronometer.
Definition: timer.h:63
U get_duration() const noexcept
Duration specified by U.
Definition: timer.h:97
const Timer & toc() noexcept
Stops the chronometer.
Definition: timer.h:72