CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/Utilities/Timing/src/TimerStack.cc

Go to the documentation of this file.
00001 #include "Utilities/Timing/interface/TimerStack.h"
00002 void TimerStack::push( std::string name, Type type ){
00003    bool linuxCpuOn = (type == DetailedMonitoring);
00004    if( (*TimingReport::current())["firstcall_"+name].counter == 0)
00005      stack.push(new TimeMe("firstcall_"+name,linuxCpuOn));
00006    else
00007      stack.push(new TimeMe(name,linuxCpuOn));
00008 }
00009 
00010 void TimerStack::push( TimerStack::Timer& timer, Type type ){
00011    bool linuxCpuOn = (type == DetailedMonitoring);
00012    if( timer.first().counter == 0)
00013      stack.push(new TimeMe(timer.first(), linuxCpuOn));
00014    else
00015      stack.push(new TimeMe(timer.main(), linuxCpuOn));
00016 }
00017 
00018 void TimerStack::pop( ){
00019    if (!stack.empty()) {
00020       delete stack.top();
00021       stack.pop();
00022    }
00023 }
00024 
00025 void TimerStack::clear_stack(){
00026    while(!stack.empty()) pop();
00027 }
00028    
00029 void TimerStack::pop_and_push(std::string name, Type type ) {
00030    pop();
00031    push(name,type);
00032 }
00033 void TimerStack::pop_and_push( TimerStack::Timer& timer, Type type ) {
00034    pop();
00035    push(timer,type);
00036 }
00037 
00038 void TimerStack::benchmark( std::string name, int n )
00039 {
00040    push(name,FastMonitoring);
00041    float a(1.0009394);
00042    float b(0.000123);
00043    for(int i=0; i < n; i++) b *= a;
00044    pop();
00045 }