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>
47 class Timer :
public IDisplay {
49 typename CLOCK_T::time_point start_, end_;
55 Timer() noexcept : start_{CLOCK_T::now()}, end_{start_} {}
60 virtual ~Timer() =
default;
69 Timer& tic() noexcept {
70 start_ = end_ = CLOCK_T::now();
82 Timer& toc() noexcept {
83 end_ = CLOCK_T::now();
94 double tics() const noexcept {
95 return std::chrono::duration_cast<T>(end_ - start_).count();
107 template <
typename U = T>
108 U get_duration() const noexcept {
109 return std::chrono::duration_cast<U>(end_ - start_);
123 std::ostream& display(std::ostream& os)
const override {
Quantum++ main namespace.
Definition: circuits.h:35