CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
edm::ChildrenCPUTimer Class Reference

#include <ChildrenCPUTimer.h>

Public Member Functions

void add (double t)
 
 ChildrenCPUTimer ()
 
 ChildrenCPUTimer (ChildrenCPUTimer &&)=default
 
 ChildrenCPUTimer (const ChildrenCPUTimer &)=delete
 
double cpuTime () const
 
ChildrenCPUTimeroperator= (const ChildrenCPUTimer &)=delete
 
void reset ()
 
void start ()
 
double stop ()
 
 ~ChildrenCPUTimer ()
 

Private Types

enum  State { kRunning, kStopped }
 

Private Member Functions

double calculateDeltaTime () const
 

Private Attributes

double accumulatedCPUTime_
 
struct timeval startCPUTime_
 
enum edm::ChildrenCPUTimer::State state_
 

Detailed Description

Definition at line 28 of file ChildrenCPUTimer.h.

Member Enumeration Documentation

◆ State

Enumerator
kRunning 
kStopped 

Definition at line 52 of file ChildrenCPUTimer.h.

Constructor & Destructor Documentation

◆ ChildrenCPUTimer() [1/3]

ChildrenCPUTimer::ChildrenCPUTimer ( )

Definition at line 33 of file ChildrenCPUTimer.cc.

References startCPUTime_.

34  startCPUTime_.tv_sec = 0;
35  startCPUTime_.tv_usec = 0;
36 }
enum edm::ChildrenCPUTimer::State state_
struct timeval startCPUTime_

◆ ~ChildrenCPUTimer()

ChildrenCPUTimer::~ChildrenCPUTimer ( )

Definition at line 38 of file ChildrenCPUTimer.cc.

38 {}

◆ ChildrenCPUTimer() [2/3]

edm::ChildrenCPUTimer::ChildrenCPUTimer ( ChildrenCPUTimer &&  )
default

◆ ChildrenCPUTimer() [3/3]

edm::ChildrenCPUTimer::ChildrenCPUTimer ( const ChildrenCPUTimer )
delete

Member Function Documentation

◆ add()

void ChildrenCPUTimer::add ( double  t)

◆ calculateDeltaTime()

double ChildrenCPUTimer::calculateDeltaTime ( ) const
private

Definition at line 70 of file ChildrenCPUTimer.cc.

References Exception, and startCPUTime_.

Referenced by cpuTime(), and stop().

70  {
71  double returnValue;
72  double const microsecToSec = 1E-6;
73 
74  rusage theUsage;
75  if (0 != getrusage(RUSAGE_CHILDREN, &theUsage)) {
76  throw cms::Exception("CPUTimerFailed") << errno;
77  }
78 
79  returnValue = theUsage.ru_stime.tv_sec + theUsage.ru_utime.tv_sec - startCPUTime_.tv_sec +
80  microsecToSec * (theUsage.ru_stime.tv_usec + theUsage.ru_utime.tv_usec - startCPUTime_.tv_usec);
81  return returnValue;
82 }
struct timeval startCPUTime_

◆ cpuTime()

double ChildrenCPUTimer::cpuTime ( ) const

Definition at line 86 of file ChildrenCPUTimer.cc.

References accumulatedCPUTime_, calculateDeltaTime(), kStopped, and state_.

Referenced by edm::SystemTimeKeeper::fillTriggerTimingReport().

86  {
87  if (kStopped == state_) {
88  return accumulatedCPUTime_;
89  }
91 }
double calculateDeltaTime() const
enum edm::ChildrenCPUTimer::State state_

◆ operator=()

ChildrenCPUTimer& edm::ChildrenCPUTimer::operator= ( const ChildrenCPUTimer )
delete

◆ reset()

void ChildrenCPUTimer::reset ( void  )

Definition at line 66 of file ChildrenCPUTimer.cc.

References accumulatedCPUTime_.

◆ start()

void ChildrenCPUTimer::start ( )

Definition at line 43 of file ChildrenCPUTimer.cc.

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

Referenced by progressbar.ProgressBar::__next__(), and edm::SystemTimeKeeper::startProcessingLoop().

43  {
44  if (kStopped == state_) {
45  rusage theUsage;
46  if (0 != getrusage(RUSAGE_CHILDREN, &theUsage)) {
47  throw cms::Exception("ChildrenCPUTimerFailed") << errno;
48  }
49  startCPUTime_.tv_sec = theUsage.ru_stime.tv_sec + theUsage.ru_utime.tv_sec;
50  startCPUTime_.tv_usec = theUsage.ru_stime.tv_usec + theUsage.ru_utime.tv_usec;
51  state_ = kRunning;
52  }
53 }
enum edm::ChildrenCPUTimer::State state_
struct timeval startCPUTime_

◆ stop()

double ChildrenCPUTimer::stop ( )

Definition at line 55 of file ChildrenCPUTimer.cc.

References accumulatedCPUTime_, calculateDeltaTime(), kRunning, kStopped, state_, and submitPVValidationJobs::t.

Referenced by edm::SystemTimeKeeper::stopProcessingLoop().

55  {
56  if (kRunning == state_) {
57  auto t = calculateDeltaTime();
59 
60  state_ = kStopped;
61  return t;
62  }
63  return 0.;
64 }
double calculateDeltaTime() const
enum edm::ChildrenCPUTimer::State state_

Member Data Documentation

◆ accumulatedCPUTime_

double edm::ChildrenCPUTimer::accumulatedCPUTime_
private

Definition at line 55 of file ChildrenCPUTimer.h.

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

◆ startCPUTime_

struct timeval edm::ChildrenCPUTimer::startCPUTime_
private

Definition at line 53 of file ChildrenCPUTimer.h.

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

◆ state_

enum edm::ChildrenCPUTimer::State edm::ChildrenCPUTimer::state_
private

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