CMS 3D CMS Logo

CPUTimer.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_CPUTimer_h
2 #define FWCore_Utilities_CPUTimer_h
3 // -*- C++ -*-
4 //
5 // Package: Utilities
6 // Class : CPUTimer
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 {
37  class CPUTimer {
38  public:
39  CPUTimer();
40  ~CPUTimer();
41  CPUTimer(CPUTimer&&) = default;
42 
43  struct Times {
44  Times() : real_(0), cpu_(0) {}
45  double real_;
46  double cpu_;
47  };
48 
49  // ---------- const member functions ---------------------
50  double realTime() const;
51  double cpuTime() const;
52 
53  // ---------- static member functions --------------------
54 
55  // ---------- member functions ---------------------------
56  void start();
57  Times stop(); //returns delta time
58  void reset();
59 
60  void add(const Times& t);
61 
62  private:
63  CPUTimer(const CPUTimer&) = delete; // stop default
64 
65  const CPUTimer& operator=(const CPUTimer&) = delete; // stop default
66 
67  Times calculateDeltaTime() const;
68 
69  // ---------- member data --------------------------------
71 #ifdef USE_CLOCK_GETTIME
72  struct timespec startRealTime_;
73  struct timespec startCPUTime_;
74 #else
75  struct timeval startRealTime_;
76  struct timeval startCPUTime_;
77 #endif
78 
81  };
82 } // namespace edm
83 
84 #endif
edm::CPUTimer::state_
enum edm::CPUTimer::State state_
edm::CPUTimer::Times::real_
double real_
Definition: CPUTimer.h:45
edm::CPUTimer::State
State
Definition: CPUTimer.h:70
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::CPUTimer
Definition: CPUTimer.h:37
edm::CPUTimer::Times
Definition: CPUTimer.h:43
edm::CPUTimer::start
void start()
Definition: CPUTimer.cc:68
edm::CPUTimer::startCPUTime_
struct timeval startCPUTime_
Definition: CPUTimer.h:76
OrderedSet.t
t
Definition: OrderedSet.py:90
edm::CPUTimer::reset
void reset()
Definition: CPUTimer.cc:99
edm::CPUTimer::~CPUTimer
~CPUTimer()
Definition: CPUTimer.cc:52
edm::CPUTimer::CPUTimer
CPUTimer()
Definition: CPUTimer.cc:33
edm::CPUTimer::stop
Times stop()
Definition: CPUTimer.cc:87
edm::CPUTimer::operator=
const CPUTimer & operator=(const CPUTimer &)=delete
edm::CPUTimer::kRunning
Definition: CPUTimer.h:70
edm::CPUTimer::cpuTime
double cpuTime() const
Definition: CPUTimer.cc:146
edm::CPUTimer::accumulatedCPUTime_
double accumulatedCPUTime_
Definition: CPUTimer.h:80
edm::CPUTimer::Times::cpu_
double cpu_
Definition: CPUTimer.h:46
edm::CPUTimer::kStopped
Definition: CPUTimer.h:70
edm::CPUTimer::realTime
double realTime() const
Definition: CPUTimer.cc:139
edm::CPUTimer::startRealTime_
struct timeval startRealTime_
Definition: CPUTimer.h:75
edm::CPUTimer::Times::Times
Times()
Definition: CPUTimer.h:44
edm::CPUTimer::add
void add(const Times &t)
Definition: CPUTimer.cc:104
edm::CPUTimer::accumulatedRealTime_
double accumulatedRealTime_
Definition: CPUTimer.h:79
edm::CPUTimer::calculateDeltaTime
Times calculateDeltaTime() const
Definition: CPUTimer.cc:109