AI 24/25 Project Software
Documentation for the AI 24/25 course programming project software
Loading...
Searching...
No Matches
timer.h
1#ifndef UTILS_TIMER_H
2#define UTILS_TIMER_H
3
4#include "downward/utils/system.h"
5
6#include <ostream>
7
8namespace utils {
9class Duration {
10 double seconds;
11
12public:
13 explicit Duration(double seconds)
14 : seconds(seconds)
15 {
16 }
17 operator double() const { return seconds; }
18};
19
20std::ostream& operator<<(std::ostream& os, const Duration& time);
21
22class Timer {
23 double last_start_clock;
24 double collected_time;
25 bool stopped;
26#if OPERATING_SYSTEM == WINDOWS
27 LARGE_INTEGER frequency;
28 LARGE_INTEGER start_ticks;
29#endif
30
31 double current_clock() const;
32
33public:
34 explicit Timer(bool start = true);
35 ~Timer() = default;
36 Duration operator()() const;
37 Duration stop();
38 void resume();
39 Duration reset();
40};
41
42std::ostream& operator<<(std::ostream& os, const Timer& timer);
43
44extern Timer g_search_timer;
45extern Timer g_timer;
46} // namespace utils
47
48#endif