Bridge++  Ver. 1.1.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
timer.h
Go to the documentation of this file.
1 
14 #ifndef TIMER_INCLUDED
15 #define TIMER_INCLUDED
16 
17 //#define USE_RUSAGE
18 #undef USE_RUSAGE
19 
20 #ifdef USE_RUSAGE
21 #include <sys/resource.h>
22 #endif
23 
24 #include <cstdio>
25 #include <time.h>
26 #include <sys/time.h>
27 
28 #include "bridgeIO.h"
29 using Bridge::vout;
30 
31 
32 class Timer {
33  public:
34  Timer() : is_started(false), m_start(0), m_elapsed(0), m_counter(0) {}
35  ~Timer() {}
36 
37  void start();
38  void stop();
39  void reset();
40 
41  void timestamp();
42 
43  double elapsed_msec() const;
44  unsigned long get_counter() const;
45 
46  private:
47  bool is_started;
48  double m_start;
49 
50  double m_elapsed; // sec.
51  unsigned long m_counter;
52 };
53 #endif /* _TIMER_H_ */