idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
Timer.h
1//
2// Created by henri on 10/10/22.
3//
4
5#ifndef OPTIMIZE_TIMER_H
6#define OPTIMIZE_TIMER_H
7
8#include <chrono>
9
10namespace idol {
11 class Timer;
12}
13
18 using time = std::chrono::high_resolution_clock::time_point;
19 using duration = std::chrono::duration<double>;
20 bool m_has_started = false, m_has_stopped = false;
21 time m_starting_clock;
22 time m_ending_clock;
23 duration m_cumulative = duration(0);
24
25 [[nodiscard]] duration as_duration() const;
26public:
27 enum Unit { Seconds, Milliseconds, Microseconds };
28
32 void start();
33
37 void stop();
38
44 [[nodiscard]] double count(Unit t_unit = Seconds) const;
45
51 [[nodiscard]] double cumulative_count(Unit t_unit = Seconds) const;
52
53 [[nodiscard]] double factor(Unit t_unit) const;
54};
55
56#endif //OPTIMIZE_TIMER_H
double cumulative_count(Unit t_unit=Seconds) const
double count(Unit t_unit=Seconds) const
void start()