CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
WallclockTimer.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_WallclockTimer_h
2 #define FWCore_Utilities_WallclockTimer_h
3 // -*- C++ -*-
4 //
5 // Package: Utilities
6 // Class : WallclockTimer
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Sun Apr 16 20:32:13 EDT 2006
19 //
20 
21 // system include files
22 #ifdef __linux__
23 //clock_gettime is not available on OS X
24 #define USE_CLOCK_GETTIME
25 #endif
26 
27 #ifdef USE_CLOCK_GETTIME
28 #include <ctime>
29 #else
30 #include <sys/time.h>
31 #endif
32 
33 // user include files
34 
35 // forward declarations
36 namespace edm {
38  public:
41  WallclockTimer(WallclockTimer&&) = default;
42  WallclockTimer(const WallclockTimer&) = delete;
43  WallclockTimer& operator=(const WallclockTimer&) = delete;
44 
45  // ---------- const member functions ---------------------
46  double realTime() const;
47 
48  // ---------- static member functions --------------------
49 
50  // ---------- member functions ---------------------------
51  void start();
52  double stop(); //returns delta time
53  void reset();
54 
55  void add(double t);
56 
57  private:
58  double calculateDeltaTime() const;
59 
60  // ---------- member data --------------------------------
62 #ifdef USE_CLOCK_GETTIME
63  struct timespec startRealTime_;
64 #else
65  struct timeval startRealTime_;
66 #endif
67 
69  };
70 } // namespace edm
71 
72 #endif
double calculateDeltaTime() const
double realTime() const
void add(double t)
enum edm::WallclockTimer::State state_
struct timeval startRealTime_
WallclockTimer & operator=(const WallclockTimer &)=delete