CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
R2DTimerObserver.h
Go to the documentation of this file.
1 #ifndef SiPixelRawToDigi_R2DTimerObserver_H
2 #define SiPixelRawToDigi_R2DTimerObserver_H
3 
4 #include <string>
6 
15 
16 
17 private:
18 
20 
22  public:
23  LastMeasurement(double real=0., double cpu=0.) : real_(real), cpu_(cpu) { }
24  double real() const { return real_;}
25  double cpu() const { return cpu_;}
26  private:
27  double real_,cpu_;
28  };
29 
33 
35  virtual void operator()(const TimerState & timerState) {
36  theMeasurement = LastMeasurement(timerState.first-lastState.first,
37  timerState.second-lastState.second);
38  lastState = timerState;
39  }
40 
41 public:
42 
43  void init(const std::string & name) {
44  timer_item = &(*TimingReport::current())[name];
45  timer_item->switchCPU(false);
46  timer_item->setObs(this);
47  }
48 
50  R2DTimerObserver(const std::string name) : lastState(0,0) { init( name) ; }
51 
54 
55  void start() { timer_item->start(); }
56  void stop() { timer_item->stop(); }
57 
58 };
59 
60 #endif
virtual void operator()(const TimerState &timerState)
from base class
LastMeasurement theMeasurement
TimingReport::Item & item()
LastMeasurement(double real=0., double cpu=0.)
TimerState lastState
TimingReport::ItemObserver::event TimerState
static TimingReport * current()
Definition: TimingReport.cc:21
const LastMeasurement & lastMeasurement()
void setObs(MyObserver *io)
Definition: TimingReport.h:44
R2DTimerObserver(const std::string name)
TimingReport::Item * timer_item
Item & switchCPU(bool ion)
Definition: TimingReport.h:31
void init(const std::string &name)