Camargue
timer.hpp
1 #ifndef CMR_TIMER_HPP
2 #define CMR_TIMER_HPP
3 
4 #include <chrono>
5 #include <string>
6 
7 namespace CMR {
8 
10 class Timer {
11 public:
12  Timer();
14  Timer(const std::string &tname);
20  Timer(const std::string &tname, const Timer *_ratio_timer);
21 
23  void start();
24 
26  void stop();
27 
29  void resume();
30 
36  void report(bool show_cpu) const;
37 
38 private:
39 
44  std::string timer_name;
45 
47  std::chrono::duration<double> wall_elapsed;
48 
50  double cpu_elapsed;
51 
53  std::chrono::time_point<std::chrono::system_clock> wall_start;
54 
56  std::chrono::time_point<std::chrono::system_clock> wall_end;
57 
59  double cpu_start;
60 
62  double cpu_end;
63 
70 };
71 
72 }
73 
74 #endif
std::chrono::duration< double > wall_elapsed
Elapsed wall clock or stopwatch time.
Definition: timer.hpp:47
double cpu_end
CPU clock end time.
Definition: timer.hpp:62
void report(bool show_cpu) const
Reports the elapsed times and ratios if applicable.
Definition: timer.cpp:66
std::string timer_name
The name of the Timer.
Definition: timer.hpp:44
void resume()
Start accumulating time without resetting elapsed times.
Definition: timer.cpp:60
std::chrono::time_point< std::chrono::system_clock > wall_start
Wall clock start time.
Definition: timer.hpp:53
Timer()
Construct unnamed timer.
Definition: timer.cpp:21
std::chrono::time_point< std::chrono::system_clock > wall_end
Wall clock end time.
Definition: timer.hpp:56
void stop()
Stop accumulating times and add them to elapsed times.
Definition: timer.cpp:51
A class for recording CPU and wall clock time.
Definition: timer.hpp:10
void start()
Start accumulating time at current time, resetting elapsed times.
Definition: timer.cpp:43
double cpu_start
CPU clock start time.
Definition: timer.hpp:59
The namespace for this project.
Definition: abc_nodesel.hpp:20
const Timer * ratio_timer
For use by report to report elapsed times as ratio of other timer.
Definition: timer.hpp:69
double cpu_elapsed
Elapsed CPU time.
Definition: timer.hpp:50