CMS 3D CMS Logo

edm::CPUTimer Class Reference

#include <FWCore/Utilities/interface/CPUTimer.h>

List of all members.

Public Member Functions

double cpuTime () const
 CPUTimer ()
double realTime () const
void reset ()
void start ()
void stop ()
virtual ~CPUTimer ()

Private Types

enum  State { kRunning, kStopped }

Private Member Functions

Times calculateDeltaTime () const
 CPUTimer (const CPUTimer &)
const CPUTimeroperator= (const CPUTimer &)

Private Attributes

double accumulatedCPUTime_
double accumulatedRealTime_
struct timeval startCPUTime_
struct timeval startRealTime_
enum edm::CPUTimer::State state_

Classes

struct  Times


Detailed Description

Definition at line 29 of file CPUTimer.h.


Member Enumeration Documentation

enum edm::CPUTimer::State [private]

Enumerator:
kRunning 
kStopped 

Definition at line 60 of file CPUTimer.h.


Constructor & Destructor Documentation

CPUTimer::CPUTimer (  ) 

Definition at line 34 of file CPUTimer.cc.

References startCPUTime_, and startRealTime_.

00034                    :
00035 state_(kStopped),
00036 startRealTime_(),
00037 startCPUTime_(),
00038 accumulatedRealTime_(0),
00039 accumulatedCPUTime_(0)
00040 {
00041   startRealTime_.tv_sec=0;
00042   startRealTime_.tv_usec=0;
00043   startCPUTime_.tv_sec=0;
00044   startCPUTime_.tv_usec=0;
00045 }

CPUTimer::~CPUTimer (  )  [virtual]

Definition at line 52 of file CPUTimer.cc.

00053 {
00054 }

edm::CPUTimer::CPUTimer ( const CPUTimer  )  [private]


Member Function Documentation

CPUTimer::Times CPUTimer::calculateDeltaTime (  )  const [private]

Definition at line 103 of file CPUTimer.cc.

References edm::CPUTimer::Times::cpu_, Exception, edm::CPUTimer::Times::real_, startCPUTime_, and startRealTime_.

Referenced by cpuTime(), realTime(), and stop().

00104 {
00105   rusage theUsage;
00106   if( 0 != getrusage(RUSAGE_SELF, &theUsage)) {
00107     throw cms::Exception("CPUTimerFailed")<<errno;
00108   }
00109   const double microsecToSec = 1E-6;
00110   
00111   struct timeval tp;
00112   gettimeofday(&tp, 0);
00113   
00114   Times returnValue;
00115   returnValue.cpu_ = theUsage.ru_stime.tv_sec+theUsage.ru_utime.tv_sec-startCPUTime_.tv_sec+microsecToSec*(theUsage.ru_stime.tv_usec+theUsage.ru_utime.tv_usec-startCPUTime_.tv_usec);
00116   returnValue.real_ = tp.tv_sec-startRealTime_.tv_sec+microsecToSec*(tp.tv_usec -startRealTime_.tv_usec);
00117   return returnValue;
00118 }

double CPUTimer::cpuTime (  )  const

Definition at line 132 of file CPUTimer.cc.

References accumulatedCPUTime_, calculateDeltaTime(), edm::CPUTimer::Times::cpu_, kStopped, and state_.

Referenced by HcalHotCellClient::analyze(), HcalDigiClient::analyze(), HcalMonitorModule::analyze(), HcalMonitorClient::analyze(), HcalHotCellClient::beginJob(), HcalHotCellClient::beginRun(), HcalHotCellClient::cleanup(), HcalHotCellClient::endJob(), HcalHotCellClient::endRun(), HcalDigiMonitor::fill_Nevents(), HcalPedestalMonitor::fillDBValues(), HcalRecHitMonitor::fillNevents(), HcalHotCellMonitor::fillNevents_energy(), HcalDeadCellMonitor::fillNevents_energy(), HcalDeadCellMonitor::fillNevents_neighbor(), HcalHotCellMonitor::fillNevents_neighbor(), HcalDeadCellMonitor::fillNevents_occupancy(), HcalDeadCellMonitor::fillNevents_pedestal(), HcalHotCellMonitor::fillNevents_pedestal(), HcalHotCellMonitor::fillNevents_persistentenergy(), HcalHotCellMonitor::fillNevents_problemCells(), HcalDeadCellMonitor::fillNevents_problemCells(), HcalPedestalMonitor::fillPedestalHistos(), HcalHotCellClient::getHistograms(), HcalDigiClient::getHistograms(), HcalTrigPrimClient::getHistograms(), HcalHotCellClient::htmlExpertOutput(), HcalDeadCellClient::htmlExpertOutput(), HcalRecHitClient::htmlExpertOutput(), HcalDigiClient::htmlExpertOutput(), HcalBeamClient::htmlExpertOutput(), HcalPedestalClient::htmlExpertOutput(), HcalHotCellClient::htmlOutput(), HcalDeadCellClient::htmlOutput(), HcalPedestalClient::htmlOutput(), HcalBeamClient::htmlOutput(), HcalRecHitClient::htmlOutput(), HcalTrigPrimClient::htmlOutput(), HcalDigiClient::htmlOutput(), HcalDigiClient::init(), HcalHotCellClient::init(), HcalTrigPrimClient::init(), HcalHotCellClient::loadHistograms(), TimerService::postModule(), edm::service::PathTimerService::postModule(), HcalDigiMonitor::processEvent(), stor::EventServer::processEvent(), HcalBeamMonitor::processEvent(), HcalPedestalMonitor::processEvent(), HcalDeadCellMonitor::processEvent_digi(), HcalHotCellMonitor::processEvent_pedestal(), HcalRecHitMonitor::processEvent_rechit(), HcalDeadCellMonitor::processEvent_rechitenergy(), HcalHotCellMonitor::processEvent_rechitenergy(), HcalHotCellMonitor::processEvent_rechitneighbors(), HcalDeadCellMonitor::processEvent_rechitneighbors(), HcalDigiClient::report(), HcalHotCellClient::report(), HcalTrigPrimClient::report(), HcalTrigPrimClient::resetAllME(), HcalDigiClient::resetAllME(), HcalHotCellClient::resetAllME(), HcalPedestalMonitor::setup(), HcalDigiMonitor::setup(), HcalBaseMonitor::setupDepthHists1D(), and HcalBaseMonitor::setupDepthHists2D().

00133 { 
00134   if(kStopped== state_) {
00135     return accumulatedCPUTime_;
00136   }
00137   return accumulatedCPUTime_+ calculateDeltaTime().cpu_;
00138 }

const CPUTimer& edm::CPUTimer::operator= ( const CPUTimer  )  [private]

double CPUTimer::realTime (  )  const

Definition at line 123 of file CPUTimer.cc.

References accumulatedRealTime_, calculateDeltaTime(), kStopped, edm::CPUTimer::Times::real_, and state_.

Referenced by stor::DataProcessManager::getOneDQMEventFromSM(), stor::DataProcessManager::getOneEventFromSM(), TimerService::postModule(), edm::service::PathTimerService::postModule(), and stor::EventServer::processEvent().

00124 { 
00125   if(kStopped == state_) {
00126     return accumulatedRealTime_;
00127   }
00128   return accumulatedRealTime_ + calculateDeltaTime().real_; 
00129 }

void CPUTimer::reset ( void   ) 

Definition at line 97 of file CPUTimer.cc.

References accumulatedCPUTime_, and accumulatedRealTime_.

Referenced by HcalHotCellClient::analyze(), HcalDigiClient::analyze(), HcalMonitorModule::analyze(), HcalMonitorClient::analyze(), HcalHotCellClient::beginJob(), HcalHotCellClient::cleanup(), HcalDeadCellMonitor::createMaps(), HcalHotCellMonitor::createMaps(), HcalDigiClient::createTests(), HcalHotCellClient::endJob(), HcalHotCellClient::endRun(), stor::EventServer::EventServer(), HcalDigiMonitor::fill_Nevents(), HcalPedestalMonitor::fillDBValues(), HcalRecHitMonitor::fillNevents(), HcalHotCellMonitor::fillNevents_energy(), HcalDeadCellMonitor::fillNevents_energy(), HcalDeadCellMonitor::fillNevents_neighbor(), HcalHotCellMonitor::fillNevents_neighbor(), HcalDeadCellMonitor::fillNevents_occupancy(), HcalDeadCellMonitor::fillNevents_pedestal(), HcalHotCellMonitor::fillNevents_pedestal(), HcalHotCellMonitor::fillNevents_persistentenergy(), HcalHotCellMonitor::fillNevents_problemCells(), HcalDeadCellMonitor::fillNevents_problemCells(), HcalPedestalMonitor::fillPedestalHistos(), HcalHotCellClient::getHistograms(), HcalDigiClient::getHistograms(), HcalTrigPrimClient::getHistograms(), stor::DataProcessManager::getOneDQMEventFromSM(), stor::DataProcessManager::getOneEventFromSM(), HcalHotCellClient::htmlExpertOutput(), HcalDeadCellClient::htmlExpertOutput(), HcalRecHitClient::htmlExpertOutput(), HcalDigiClient::htmlExpertOutput(), HcalPedestalClient::htmlExpertOutput(), HcalBeamClient::htmlExpertOutput(), HcalHotCellClient::htmlOutput(), HcalPedestalClient::htmlOutput(), HcalDeadCellClient::htmlOutput(), HcalBeamClient::htmlOutput(), HcalRecHitClient::htmlOutput(), HcalTrigPrimClient::htmlOutput(), HcalDigiClient::htmlOutput(), HcalDigiClient::init(), HcalHotCellClient::init(), HcalTrigPrimClient::init(), HcalHotCellClient::loadHistograms(), edm::service::PathTimerService::postModule(), TimerService::preModule(), edm::service::PathTimerService::preModule(), HcalRecHitMonitor::processEvent(), HcalDigiMonitor::processEvent(), HcalDeadCellMonitor::processEvent(), stor::EventServer::processEvent(), HcalHotCellMonitor::processEvent(), HcalBeamMonitor::processEvent(), HcalPedestalMonitor::processEvent(), HcalDeadCellMonitor::processEvent_digi(), HcalHotCellMonitor::processEvent_pedestal(), HcalRecHitMonitor::processEvent_rechit(), HcalDeadCellMonitor::processEvent_rechitenergy(), HcalHotCellMonitor::processEvent_rechitenergy(), HcalHotCellMonitor::processEvent_rechitneighbors(), HcalDeadCellMonitor::processEvent_rechitneighbors(), HcalDigiClient::report(), HcalHotCellClient::report(), HcalTrigPrimClient::report(), HcalTrigPrimClient::resetAllME(), HcalDigiClient::resetAllME(), HcalHotCellClient::resetAllME(), HcalPedestalMonitor::setup(), HcalRecHitMonitor::setup(), HcalDigiMonitor::setup(), HcalDeadCellMonitor::setup(), HcalHotCellMonitor::setup(), HcalBaseMonitor::setupDepthHists1D(), and HcalBaseMonitor::setupDepthHists2D().

00097                {
00098   accumulatedCPUTime_ =0;
00099   accumulatedRealTime_=0;
00100 }

void CPUTimer::start ( void   ) 

Definition at line 72 of file CPUTimer.cc.

References Exception, kRunning, kStopped, startCPUTime_, startRealTime_, and state_.

Referenced by HcalHotCellClient::analyze(), HcalDigiClient::analyze(), HcalMonitorModule::analyze(), HcalMonitorClient::analyze(), HcalHotCellClient::beginJob(), HcalHotCellClient::cleanup(), HcalDeadCellMonitor::createMaps(), HcalHotCellMonitor::createMaps(), HcalDigiClient::createTests(), HcalHotCellClient::endJob(), HcalHotCellClient::endRun(), HcalDigiMonitor::fill_Nevents(), HcalPedestalMonitor::fillDBValues(), HcalRecHitMonitor::fillNevents(), HcalHotCellMonitor::fillNevents_energy(), HcalDeadCellMonitor::fillNevents_energy(), HcalDeadCellMonitor::fillNevents_neighbor(), HcalHotCellMonitor::fillNevents_neighbor(), HcalDeadCellMonitor::fillNevents_occupancy(), HcalDeadCellMonitor::fillNevents_pedestal(), HcalHotCellMonitor::fillNevents_pedestal(), HcalHotCellMonitor::fillNevents_persistentenergy(), HcalHotCellMonitor::fillNevents_problemCells(), HcalDeadCellMonitor::fillNevents_problemCells(), HcalPedestalMonitor::fillPedestalHistos(), HcalHotCellClient::getHistograms(), HcalDigiClient::getHistograms(), HcalTrigPrimClient::getHistograms(), stor::DataProcessManager::getOneDQMEventFromSM(), stor::DataProcessManager::getOneEventFromSM(), HcalHotCellClient::htmlExpertOutput(), HcalDeadCellClient::htmlExpertOutput(), HcalRecHitClient::htmlExpertOutput(), HcalDigiClient::htmlExpertOutput(), HcalPedestalClient::htmlExpertOutput(), HcalBeamClient::htmlExpertOutput(), HcalHotCellClient::htmlOutput(), HcalPedestalClient::htmlOutput(), HcalDeadCellClient::htmlOutput(), HcalBeamClient::htmlOutput(), HcalRecHitClient::htmlOutput(), HcalTrigPrimClient::htmlOutput(), HcalDigiClient::htmlOutput(), HcalDigiClient::init(), HcalHotCellClient::init(), HcalTrigPrimClient::init(), HcalHotCellClient::loadHistograms(), TimerService::preModule(), edm::service::PathTimerService::preModule(), HcalRecHitMonitor::processEvent(), HcalDigiMonitor::processEvent(), HcalDeadCellMonitor::processEvent(), stor::EventServer::processEvent(), HcalHotCellMonitor::processEvent(), HcalBeamMonitor::processEvent(), HcalPedestalMonitor::processEvent(), HcalDeadCellMonitor::processEvent_digi(), HcalHotCellMonitor::processEvent_pedestal(), HcalRecHitMonitor::processEvent_rechit(), HcalDeadCellMonitor::processEvent_rechitenergy(), HcalHotCellMonitor::processEvent_rechitenergy(), HcalHotCellMonitor::processEvent_rechitneighbors(), HcalDeadCellMonitor::processEvent_rechitneighbors(), HcalDigiClient::report(), HcalHotCellClient::report(), HcalTrigPrimClient::report(), HcalTrigPrimClient::resetAllME(), HcalDigiClient::resetAllME(), HcalHotCellClient::resetAllME(), HcalPedestalMonitor::setup(), HcalRecHitMonitor::setup(), HcalDigiMonitor::setup(), HcalDeadCellMonitor::setup(), HcalHotCellMonitor::setup(), HcalBaseMonitor::setupDepthHists1D(), and HcalBaseMonitor::setupDepthHists2D().

00072                 {
00073   if(kStopped == state_) {
00074     rusage theUsage;
00075     if( 0 != getrusage(RUSAGE_SELF, &theUsage)) {
00076       throw cms::Exception("CPUTimerFailed")<<errno;
00077     }
00078     startCPUTime_.tv_sec =theUsage.ru_stime.tv_sec+theUsage.ru_utime.tv_sec;
00079     startCPUTime_.tv_usec =theUsage.ru_stime.tv_usec+theUsage.ru_utime.tv_usec;
00080     
00081     gettimeofday(&startRealTime_, 0);
00082     state_ = kRunning;
00083   }
00084 }

void CPUTimer::stop (  ) 

Definition at line 87 of file CPUTimer.cc.

References accumulatedCPUTime_, accumulatedRealTime_, calculateDeltaTime(), edm::CPUTimer::Times::cpu_, kRunning, kStopped, edm::CPUTimer::Times::real_, state_, and t.

Referenced by HcalHotCellClient::analyze(), HcalDigiClient::analyze(), HcalMonitorModule::analyze(), HcalMonitorClient::analyze(), HcalHotCellClient::beginJob(), HcalHotCellClient::beginRun(), HcalHotCellClient::cleanup(), HcalHotCellClient::endJob(), HcalHotCellClient::endRun(), HcalDigiMonitor::fill_Nevents(), HcalPedestalMonitor::fillDBValues(), HcalRecHitMonitor::fillNevents(), HcalHotCellMonitor::fillNevents_energy(), HcalDeadCellMonitor::fillNevents_energy(), HcalDeadCellMonitor::fillNevents_neighbor(), HcalHotCellMonitor::fillNevents_neighbor(), HcalDeadCellMonitor::fillNevents_occupancy(), HcalDeadCellMonitor::fillNevents_pedestal(), HcalHotCellMonitor::fillNevents_pedestal(), HcalHotCellMonitor::fillNevents_persistentenergy(), HcalHotCellMonitor::fillNevents_problemCells(), HcalDeadCellMonitor::fillNevents_problemCells(), HcalPedestalMonitor::fillPedestalHistos(), HcalHotCellClient::getHistograms(), HcalDigiClient::getHistograms(), HcalTrigPrimClient::getHistograms(), stor::DataProcessManager::getOneDQMEventFromSM(), stor::DataProcessManager::getOneEventFromSM(), HcalHotCellClient::htmlExpertOutput(), HcalDeadCellClient::htmlExpertOutput(), HcalRecHitClient::htmlExpertOutput(), HcalDigiClient::htmlExpertOutput(), HcalPedestalClient::htmlExpertOutput(), HcalBeamClient::htmlExpertOutput(), HcalHotCellClient::htmlOutput(), HcalPedestalClient::htmlOutput(), HcalDeadCellClient::htmlOutput(), HcalBeamClient::htmlOutput(), HcalRecHitClient::htmlOutput(), HcalTrigPrimClient::htmlOutput(), HcalDigiClient::htmlOutput(), HcalDigiClient::init(), HcalHotCellClient::init(), HcalTrigPrimClient::init(), HcalHotCellClient::loadHistograms(), TimerService::postModule(), edm::service::PathTimerService::postModule(), HcalDigiMonitor::processEvent(), stor::EventServer::processEvent(), HcalBeamMonitor::processEvent(), HcalPedestalMonitor::processEvent(), HcalDeadCellMonitor::processEvent_digi(), HcalHotCellMonitor::processEvent_pedestal(), HcalRecHitMonitor::processEvent_rechit(), HcalDeadCellMonitor::processEvent_rechitenergy(), HcalHotCellMonitor::processEvent_rechitenergy(), HcalHotCellMonitor::processEvent_rechitneighbors(), HcalDeadCellMonitor::processEvent_rechitneighbors(), HcalDigiClient::report(), HcalHotCellClient::report(), HcalTrigPrimClient::report(), HcalTrigPrimClient::resetAllME(), HcalDigiClient::resetAllME(), HcalHotCellClient::resetAllME(), HcalPedestalMonitor::setup(), HcalDigiMonitor::setup(), HcalBaseMonitor::setupDepthHists1D(), and HcalBaseMonitor::setupDepthHists2D().

00087                {
00088   if(kRunning == state_) {
00089     Times t = calculateDeltaTime();
00090     accumulatedCPUTime_ += t.cpu_;
00091     accumulatedRealTime_ += t.real_;
00092     state_=kStopped;
00093   }
00094 }


Member Data Documentation

double edm::CPUTimer::accumulatedCPUTime_ [private]

Definition at line 65 of file CPUTimer.h.

Referenced by cpuTime(), reset(), and stop().

double edm::CPUTimer::accumulatedRealTime_ [private]

Definition at line 64 of file CPUTimer.h.

Referenced by realTime(), reset(), and stop().

struct timeval edm::CPUTimer::startCPUTime_ [read, private]

Definition at line 62 of file CPUTimer.h.

Referenced by calculateDeltaTime(), CPUTimer(), and start().

struct timeval edm::CPUTimer::startRealTime_ [read, private]

Definition at line 61 of file CPUTimer.h.

Referenced by calculateDeltaTime(), CPUTimer(), and start().

enum edm::CPUTimer::State edm::CPUTimer::state_ [private]

Referenced by cpuTime(), realTime(), start(), and stop().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:39:56 2009 for CMSSW by  doxygen 1.5.4