sadiqsada | 1f3f0ac | 2023-08-22 12:41:27 -0700 | [diff] [blame^] | 1 | #include <chrono> |
2 | using namespace std::chrono; | ||||
3 | class Timer { | ||||
4 | public: | ||||
5 | Timer() { start_time = steady_clock::now(); } | ||||
6 | |||||
7 | ~Timer() { stop_time = steady_clock::now(); } | ||||
8 | |||||
9 | double get_elapsed_time_ms() { | ||||
10 | auto current_time = std::chrono::steady_clock::now(); | ||||
11 | return duration_cast<milliseconds>(current_time - start_time).count(); | ||||
12 | } | ||||
13 | |||||
14 | private: | ||||
15 | time_point<steady_clock> start_time; | ||||
16 | time_point<steady_clock> stop_time; | ||||
17 | }; |