profiler  0.0
Timer.h
1 #ifndef PROFILER_SRC_MOLPRO_PROFILER_TREE_TIMER_H
2 #define PROFILER_SRC_MOLPRO_PROFILER_TREE_TIMER_H
3 
4 namespace molpro {
5 namespace profiler {
6 
40 class Timer {
41 public:
42  enum Type { cpu, wall };
43  Timer(Type type, bool is_dummy);
45  Timer(double cumulative_time, Type type, bool is_dummy);
46 
48  Timer& start();
50  Timer& stop();
51 
53  void operator+=(const Timer& other);
54 
55  double start_time() const { return m_start; };
56  double stop_time() const { return m_stop; };
58  double cumulative_time() const;
60  bool stopped() const { return m_stopped; };
62  bool dummy() const { return m_dummy; };
64  void reset();
66  Type type() const { return m_type; }
67 
68 private:
69  Type m_type;
70  double m_start = 0;
71  double m_stop = 0;
72  double m_cumulative = 0;
73  bool m_stopped = true;
74  bool m_dummy = false;
75 };
76 
77 } // namespace profiler
78 } // namespace molpro
79 
80 #endif // PROFILER_SRC_MOLPRO_PROFILER_TREE_TIMER_H
Measures cpu or wall time. Can be constructed as a dummy that is always stopped.
Definition: Timer.h:40
double stop_time() const
Definition: Timer.h:56
double cumulative_time() const
Cumulative time over all start/stop periods. If active than it includes the time from start to curren...
Definition: Timer.cpp:42
Timer & start()
start timing
Definition: Timer.cpp:20
void operator+=(const Timer &other)
updates cumulative time
Definition: Timer.cpp:51
void reset()
Reset the timer erasing all data.
Definition: Timer.cpp:53
Timer(Type type, bool is_dummy)
Definition: Timer.cpp:15
bool stopped() const
Timer is stopped and is not timing.
Definition: Timer.h:60
Type type() const
type of timer
Definition: Timer.h:66
Timer & stop()
Stops timing, storing time since creation in cumulative.
Definition: Timer.cpp:33
bool dummy() const
Timer is dummy and does nothing.
Definition: Timer.h:62
double start_time() const
Definition: Timer.h:55
Type
Definition: Timer.h:42
@ cpu
Definition: Timer.h:42
@ wall
Definition: Timer.h:42
Definition: Profiler.h:5