CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RunStopwatch.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_RunStopwatch_h
2 #define FWCore_Framework_RunStopwatch_h
3 
4 /*----------------------------------------------------------------------
5 
6 
7 Simple "guard" class as suggested by Chris Jones to start/stop the
8 Stopwatch: creating an object of type RunStopwatch starts the clock
9 pointed to, deleting it (when it goes out of scope) automatically
10 calls the destructor which stops the clock.
11 
12 ----------------------------------------------------------------------*/
13 
14 #include "boost/shared_ptr.hpp"
16 
17 namespace edm {
18 
19  class RunStopwatch {
20 
21  public:
22  typedef boost::shared_ptr<CPUTimer> StopwatchPointer;
23 
25  if(stopwatch_) {
26  stopwatch_->start();
27  }
28  }
29 
31  if(stopwatch_) {
32  stopwatch_->stop();
33  }
34  }
35 
36  private:
38 
39  };
40 
42 
43  public:
44  typedef boost::shared_ptr<CPUTimer> StopwatchPointer;
45 
46  RunDualStopwatches(const StopwatchPointer& ptr1, CPUTimer* const ptr2): stopwatch1_(ptr1),stopwatch2_(ptr2) {
47  if(stopwatch1_ && 0 != stopwatch2_) {
48  stopwatch1_->start();
49  }
50  }
51 
53  if (stopwatch1_ && 0 != stopwatch2_) {
54  stopwatch2_->add(stopwatch1_->stop());
55  }
56  }
57 
58  private:
61 
62  };
63 
64 }
65 #endif
void add(const Times &t)
Definition: CPUTimer.cc:113
RunStopwatch(const StopwatchPointer &ptr)
Definition: RunStopwatch.h:24
StopwatchPointer stopwatch_
Definition: RunStopwatch.h:37
boost::shared_ptr< CPUTimer > StopwatchPointer
Definition: RunStopwatch.h:22
StopwatchPointer stopwatch1_
Definition: RunStopwatch.h:59
RunDualStopwatches(const StopwatchPointer &ptr1, CPUTimer *const ptr2)
Definition: RunStopwatch.h:46
CPUTimer *const stopwatch2_
Definition: RunStopwatch.h:60
boost::shared_ptr< CPUTimer > StopwatchPointer
Definition: RunStopwatch.h:44