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 $Id: RunStopwatch.h,v 1.4 2010/10/30 02:41:41 chrjones Exp $
7 
8 Simple "guard" class as suggested by Chris Jones to start/stop the
9 Stopwatch: creating an object of type RunStopwatch starts the clock
10 pointed to, deleting it (when it goes out of scope) automatically
11 calls the destructor which stops the clock.
12 
13 ----------------------------------------------------------------------*/
14 
15 #include "boost/shared_ptr.hpp"
17 
18 namespace edm {
19 
20  class RunStopwatch {
21 
22  public:
23  typedef boost::shared_ptr<CPUTimer> StopwatchPointer;
24 
26  if(stopwatch_) {
27  stopwatch_->start();
28  }
29  }
30 
32  if(stopwatch_) {
33  stopwatch_->stop();
34  }
35  }
36 
37  private:
39 
40  };
41 
43 
44  public:
45  typedef boost::shared_ptr<CPUTimer> StopwatchPointer;
46 
47  RunDualStopwatches(const StopwatchPointer& ptr1, CPUTimer* const ptr2): stopwatch1_(ptr1),stopwatch2_(ptr2) {
48  if(stopwatch1_ && 0 != stopwatch2_) {
49  stopwatch1_->start();
50  }
51  }
52 
54  if (stopwatch1_ && 0 != stopwatch2_) {
55  stopwatch2_->add(stopwatch1_->stop());
56  }
57  }
58 
59  private:
62 
63  };
64 
65 }
66 #endif
void add(const Times &t)
Definition: CPUTimer.cc:113
RunStopwatch(const StopwatchPointer &ptr)
Definition: RunStopwatch.h:25
StopwatchPointer stopwatch_
Definition: RunStopwatch.h:38
boost::shared_ptr< CPUTimer > StopwatchPointer
Definition: RunStopwatch.h:23
StopwatchPointer stopwatch1_
Definition: RunStopwatch.h:60
RunDualStopwatches(const StopwatchPointer &ptr1, CPUTimer *const ptr2)
Definition: RunStopwatch.h:47
CPUTimer *const stopwatch2_
Definition: RunStopwatch.h:61
boost::shared_ptr< CPUTimer > StopwatchPointer
Definition: RunStopwatch.h:45