#include <CPUTimer.h>
Classes | |
struct | Times |
Public Member Functions | |
void | add (const Times &t) |
double | cpuTime () const |
CPUTimer () | |
double | realTime () const |
void | reset () |
void | start () |
Times | stop () |
virtual | ~CPUTimer () |
Private Types | |
enum | State { kRunning, kStopped } |
Private Member Functions | |
Times | calculateDeltaTime () const |
CPUTimer (const CPUTimer &) | |
const CPUTimer & | operator= (const CPUTimer &) |
Private Attributes | |
double | accumulatedCPUTime_ |
double | accumulatedRealTime_ |
struct timeval | startCPUTime_ |
struct timeval | startRealTime_ |
enum edm::CPUTimer::State | state_ |
Definition at line 40 of file CPUTimer.h.
enum edm::CPUTimer::State [private] |
Definition at line 74 of file CPUTimer.h.
CPUTimer::CPUTimer | ( | ) |
Definition at line 33 of file CPUTimer.cc.
References startCPUTime_, and startRealTime_.
: state_(kStopped), startRealTime_(), startCPUTime_(), accumulatedRealTime_(0), accumulatedCPUTime_(0) { #ifdef USE_CLOCK_GETTIME startRealTime_.tv_sec=0; startRealTime_.tv_nsec=0; startCPUTime_.tv_sec=0; startCPUTime_.tv_nsec=0; #else startRealTime_.tv_sec=0; startRealTime_.tv_usec=0; startCPUTime_.tv_sec=0; startCPUTime_.tv_usec=0; #endif }
CPUTimer::~CPUTimer | ( | ) | [virtual] |
Definition at line 56 of file CPUTimer.cc.
{ }
edm::CPUTimer::CPUTimer | ( | const CPUTimer & | ) | [private] |
void CPUTimer::add | ( | const Times & | t | ) |
Definition at line 113 of file CPUTimer.cc.
References accumulatedCPUTime_, accumulatedRealTime_, edm::CPUTimer::Times::cpu_, and edm::CPUTimer::Times::real_.
Referenced by edm::RunDualStopwatches::~RunDualStopwatches().
{ accumulatedCPUTime_ += t.cpu_; accumulatedRealTime_ += t.real_; }
CPUTimer::Times CPUTimer::calculateDeltaTime | ( | ) | const [private] |
Definition at line 119 of file CPUTimer.cc.
References edm::CPUTimer::Times::cpu_, Exception, edm::CPUTimer::Times::real_, startCPUTime_, and startRealTime_.
Referenced by cpuTime(), realTime(), and stop().
{ Times returnValue; #ifdef USE_CLOCK_GETTIME double const nanosecToSec = 1E-9; struct timespec tp; clock_gettime(CLOCK_REALTIME, &tp); returnValue.real_ = tp.tv_sec - startRealTime_.tv_sec + nanosecToSec * (tp.tv_nsec - startRealTime_.tv_nsec); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp); returnValue.cpu_ = tp.tv_sec - startCPUTime_.tv_sec + nanosecToSec * (tp.tv_nsec - startCPUTime_.tv_nsec); #else rusage theUsage; if(0 != getrusage(RUSAGE_SELF, &theUsage)) { throw cms::Exception("CPUTimerFailed") << errno; } double const microsecToSec = 1E-6; struct timeval tp; gettimeofday(&tp, 0); 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); returnValue.real_ = tp.tv_sec - startRealTime_.tv_sec + microsecToSec * (tp.tv_usec - startRealTime_.tv_usec); #endif return returnValue; }
double CPUTimer::cpuTime | ( | ) | const |
Definition at line 157 of file CPUTimer.cc.
References accumulatedCPUTime_, calculateDeltaTime(), edm::CPUTimer::Times::cpu_, kStopped, and state_.
Referenced by ZDCMonitorModule::analyze(), CastorMonitorModule::analyze(), TimerService::postModule(), edm::service::PathTimerService::postModule(), CastorPSMonitor::processEvent(), CastorHIMonitor::processEvent(), CastorRecHitMonitor::processEvent(), CastorDigiMonitor::processEvent(), CastorEventDisplay::processEvent(), HcalBaseMonitor::setupDepthHists1D(), and HcalBaseMonitor::setupDepthHists2D().
{ if(kStopped == state_) { return accumulatedCPUTime_; } return accumulatedCPUTime_ + calculateDeltaTime().cpu_; }
double CPUTimer::realTime | ( | ) | const |
Definition at line 149 of file CPUTimer.cc.
References accumulatedRealTime_, calculateDeltaTime(), kStopped, edm::CPUTimer::Times::real_, and state_.
Referenced by TimerService::postModule(), and edm::service::PathTimerService::postModule().
{ if(kStopped == state_) { return accumulatedRealTime_; } return accumulatedRealTime_ + calculateDeltaTime().real_; }
void CPUTimer::reset | ( | void | ) |
Definition at line 107 of file CPUTimer.cc.
References accumulatedCPUTime_, and accumulatedRealTime_.
Referenced by ZDCMonitorModule::analyze(), CastorMonitorModule::analyze(), edm::service::PathTimerService::postModule(), TimerService::preModule(), edm::service::PathTimerService::preModule(), HcalZDCMonitor::processEvent(), CastorPSMonitor::processEvent(), CastorRecHitMonitor::processEvent(), CastorHIMonitor::processEvent(), CastorDigiMonitor::processEvent(), CastorEventDisplay::processEvent(), HcalZDCMonitor::setup(), HcalBaseMonitor::setupDepthHists1D(), and HcalBaseMonitor::setupDepthHists2D().
{ accumulatedCPUTime_ = 0; accumulatedRealTime_ = 0; }
void CPUTimer::start | ( | void | ) |
Definition at line 74 of file CPUTimer.cc.
References Exception, kRunning, kStopped, startCPUTime_, startRealTime_, and state_.
Referenced by ZDCMonitorModule::analyze(), CastorMonitorModule::analyze(), TimerService::preModule(), edm::service::PathTimerService::preModule(), HcalZDCMonitor::processEvent(), CastorPSMonitor::processEvent(), CastorRecHitMonitor::processEvent(), CastorHIMonitor::processEvent(), CastorDigiMonitor::processEvent(), CastorEventDisplay::processEvent(), HcalZDCMonitor::setup(), HcalBaseMonitor::setupDepthHists1D(), and HcalBaseMonitor::setupDepthHists2D().
{ if(kStopped == state_) { #ifdef USE_CLOCK_GETTIME clock_gettime(CLOCK_REALTIME, &startRealTime_); clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &startCPUTime_); #else rusage theUsage; if(0 != getrusage(RUSAGE_SELF, &theUsage)) { throw cms::Exception("CPUTimerFailed")<<errno; } startCPUTime_.tv_sec =theUsage.ru_stime.tv_sec+theUsage.ru_utime.tv_sec; startCPUTime_.tv_usec =theUsage.ru_stime.tv_usec+theUsage.ru_utime.tv_usec; gettimeofday(&startRealTime_, 0); #endif state_ = kRunning; } }
CPUTimer::Times CPUTimer::stop | ( | ) |
Definition at line 94 of file CPUTimer.cc.
References accumulatedCPUTime_, accumulatedRealTime_, calculateDeltaTime(), edm::CPUTimer::Times::cpu_, kRunning, kStopped, edm::CPUTimer::Times::real_, state_, and matplotRender::t.
Referenced by ZDCMonitorModule::analyze(), CastorMonitorModule::analyze(), TimerService::postModule(), edm::service::PathTimerService::postModule(), CastorPSMonitor::processEvent(), CastorHIMonitor::processEvent(), CastorRecHitMonitor::processEvent(), CastorDigiMonitor::processEvent(), CastorEventDisplay::processEvent(), HcalBaseMonitor::setupDepthHists1D(), and HcalBaseMonitor::setupDepthHists2D().
{ if(kRunning == state_) { Times t = calculateDeltaTime(); accumulatedCPUTime_ += t.cpu_; accumulatedRealTime_ += t.real_; state_=kStopped; return t; } return Times(); }
double edm::CPUTimer::accumulatedCPUTime_ [private] |
double edm::CPUTimer::accumulatedRealTime_ [private] |
Definition at line 83 of file CPUTimer.h.
Referenced by add(), realTime(), reset(), and stop().
struct timeval edm::CPUTimer::startCPUTime_ [private] |
Definition at line 80 of file CPUTimer.h.
Referenced by calculateDeltaTime(), CPUTimer(), and start().
struct timeval edm::CPUTimer::startRealTime_ [private] |
Definition at line 79 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().