CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TimerStack.h
Go to the documentation of this file.
1 #ifndef Utilities_Timing_TimerStack_h
2 #define Utilities_Timing_TimerStack_h 1
3 // Package: UtiBlities/Timing
4 // Class: TimerStack
5 //
6 /*
7 
8  Description: Tool to manipulate multiple timers
9 
10  */
11 //
12 // Original Author: Dmytro Kovalskyi
13 // $Id: TimerStack.h,v 1.1 2007/04/10 06:42:57 dmytro Exp $
14 
16 #include <stack>
17 
18 
20 {
21  public:
36 
38  class Timer {
39  public:
40  Timer(const std::string& name):
41  first_( &( (*TimingReport::current())["firstcall_"+name] ) ),
42  main_( &( (*TimingReport::current())[name] ) ),
43  name_(name){}
45  TimingReport::Item& main() { return *main_; }
46  private:
47  Timer(){}
50  std::string name_;
51  };
52 
55 
57 
59  void benchmark( std::string name, int n = 1000000);
60 
62  void push( std::string name, Type type = FastMonitoring );
63  void push( Timer&, Type type = FastMonitoring );
65  void pop();
67  void clear_stack();
71  void pop_and_push( std::string name, Type type = FastMonitoring );
73 
76 
77  private:
78  std::stack<TimeMe*> stack;
80 };
81 
82 #define FastTimerStackPush(timer, name) \
83  { static TimerStack::Timer t = TimerStack::Timer(std::string(name)); \
84  timer.push( t );}
85 #endif
type
Definition: HCALResponse.h:22
void pop_and_push(std::string name, Type type=FastMonitoring)
Definition: TimerStack.cc:29
TTimer is a container for a timer name and associated timers (TimeReport::Item&#39;s) ...
Definition: TimerStack.h:38
TimingReport::Item & first()
Definition: TimerStack.h:44
Timer(const std::string &name)
Definition: TimerStack.h:40
void clear_stack()
stop all timers in the stack and clear it.
Definition: TimerStack.cc:25
TimerStack(Status status)
Definition: TimerStack.h:54
PentiumTimeType pentiumTime()
get access to the cpu clock counter on Intel and AMD cpus
Definition: TimerStack.h:75
unsigned long long int PentiumTimeType
Definition: PentiumTimer.h:10
Status status_
Definition: TimerStack.h:79
void benchmark(std::string name, int n=1000000)
measure time to perform a number of floating point multiplications (FLOPs)
Definition: TimerStack.cc:38
void pop()
stop the last timer and remove it from the stack
Definition: TimerStack.cc:18
std::stack< TimeMe * > stack
Definition: TimerStack.h:78
TimingReport::Item * main_
Definition: TimerStack.h:49
PentiumTimeType rdtscPentium()
Definition: PentiumTimer.h:13
TimingReport::Item * first_
Definition: TimerStack.h:48
void push(std::string name, Type type=FastMonitoring)
start a timer and add it to the stack
Definition: TimerStack.cc:2
TimingReport::Item & main()
Definition: TimerStack.h:45
Definition: Timer.h:43
tuple status
Definition: ntuplemaker.py:245
std::string name_
Definition: TimerStack.h:50