aGrUM  0.16.0
timer.h
Go to the documentation of this file.
1 
29 #ifndef GUM_TIMER_H
30 #define GUM_TIMER_H
31 #include <chrono>
32 
33 #include <agrum/agrum.h>
34 
35 
36 namespace gum {
37 
51  class Timer {
52  public:
53  // ============================================================================
55  // ============================================================================
57 
61  Timer();
62 
67  Timer(const Timer& timer);
68 
72  ~Timer();
73 
75  // ============================================================================
77  // ============================================================================
79 
84  Timer& operator=(const Timer& timer);
85 
87  // ============================================================================
89  // ============================================================================
91 
95  void reset();
100  double pause();
105  double resume();
106 
113  double step() const;
114 
116 
117  protected:
119  std::chrono::high_resolution_clock::time_point _start;
120 
122  std::chrono::high_resolution_clock::time_point _pause;
123 
125  bool _sleeping;
126  };
127 
128 } /* namespace gum */
129 
130 #ifndef GUM_NO_INLINE
131 # include <agrum/core/timer_inl.h>
132 #endif // GUM_NO_INLINE
133 
134 #endif // GUM_TIMER_H
std::chrono::high_resolution_clock::time_point _pause
Time of the last call to pause().
Definition: timer.h:122
double step() const
Returns the delta time between now and the last reset() call (or the constructor).
Definition: timer_inl.h:42
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
void reset()
Reset the timer.
Definition: timer_inl.h:32
Timer()
Default constructor (launching the timer).
Definition: timer.cpp:38
double pause()
Pause the timer and return the delta (.
Definition: timer_inl.h:53
bool _sleeping
False if running.
Definition: timer.h:125
double resume()
Resume the timer and return the delta (.
Definition: timer_inl.h:63
Timer & operator=(const Timer &timer)
Copy operator.
Definition: timer.cpp:50
std::chrono::high_resolution_clock::time_point _start
Time of the last call to reset() or the constructor.
Definition: timer.h:119
Class used to compute response times for benchmark purposesThis class represents a classic timer...
Definition: timer.h:51
~Timer()
Destructor.
Definition: timer.cpp:48