test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
edm::WallclockTimer Class Reference

#include <WallclockTimer.h>

Public Member Functions

void add (double t)
 
double realTime () const
 
void reset ()
 
void start ()
 
double stop ()
 
 WallclockTimer ()
 
 WallclockTimer (WallclockTimer &&)=default
 
 ~WallclockTimer ()
 

Private Types

enum  State { kRunning, kStopped }
 

Private Member Functions

double calculateDeltaTime () const
 
const WallclockTimeroperator= (const WallclockTimer &)=delete
 
 WallclockTimer (const WallclockTimer &)=delete
 

Private Attributes

double accumulatedRealTime_
 
struct timeval startRealTime_
 
enum edm::WallclockTimer::State state_
 

Detailed Description

Definition at line 37 of file WallclockTimer.h.

Member Enumeration Documentation

Enumerator
kRunning 
kStopped 

Definition at line 64 of file WallclockTimer.h.

Constructor & Destructor Documentation

WallclockTimer::WallclockTimer ( )

Definition at line 33 of file WallclockTimer.cc.

References startRealTime_.

33  :
37 {
38 #ifdef USE_CLOCK_GETTIME
39  startRealTime_.tv_sec=0;
40  startRealTime_.tv_nsec=0;
41 #else
42  startRealTime_.tv_sec=0;
43  startRealTime_.tv_usec=0;
44 #endif
45 }
enum edm::WallclockTimer::State state_
struct timeval startRealTime_
WallclockTimer::~WallclockTimer ( )

Definition at line 51 of file WallclockTimer.cc.

51  {
52 }
edm::WallclockTimer::WallclockTimer ( WallclockTimer &&  )
default
edm::WallclockTimer::WallclockTimer ( const WallclockTimer )
privatedelete

Member Function Documentation

void WallclockTimer::add ( double  t)

Definition at line 98 of file WallclockTimer.cc.

References accumulatedRealTime_, and lumiQTWidget::t.

Referenced by counter.Counter::register().

98  {
100 }
double WallclockTimer::calculateDeltaTime ( ) const
private

Definition at line 103 of file WallclockTimer.cc.

References CLOCK_MONOTONIC, and startRealTime_.

Referenced by realTime(), and stop().

103  {
104  double returnValue;
105 #ifdef USE_CLOCK_GETTIME
106  double const nanosecToSec = 1E-9;
107  struct timespec tp;
108 
109  clock_gettime(CLOCK_MONOTONIC, &tp);
110  returnValue = tp.tv_sec - startRealTime_.tv_sec + nanosecToSec * (tp.tv_nsec - startRealTime_.tv_nsec);
111 #else
112  double const microsecToSec = 1E-6;
113 
114  struct timeval tp;
115  gettimeofday(&tp, 0);
116 
117  returnValue = tp.tv_sec - startRealTime_.tv_sec + microsecToSec * (tp.tv_usec - startRealTime_.tv_usec);
118 #endif
119  return returnValue;
120 }
#define CLOCK_MONOTONIC
Definition: TimerService.h:33
struct timeval startRealTime_
const WallclockTimer& edm::WallclockTimer::operator= ( const WallclockTimer )
privatedelete
double WallclockTimer::realTime ( ) const

Definition at line 125 of file WallclockTimer.cc.

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

125  {
126  if(kStopped == state_) {
127  return accumulatedRealTime_;
128  }
130 }
double calculateDeltaTime() const
enum edm::WallclockTimer::State state_
void WallclockTimer::reset ( void  )

Definition at line 93 of file WallclockTimer.cc.

References accumulatedRealTime_.

93  {
95 }
void WallclockTimer::start ( void  )

Definition at line 69 of file WallclockTimer.cc.

References CLOCK_MONOTONIC, kRunning, kStopped, startRealTime_, and state_.

Referenced by progressbar.ProgressBar::__next__().

69  {
70  if(kStopped == state_) {
71 #ifdef USE_CLOCK_GETTIME
72  clock_gettime(CLOCK_MONOTONIC, &startRealTime_);
73 #else
74  gettimeofday(&startRealTime_, 0);
75 #endif
76  state_ = kRunning;
77  }
78 }
#define CLOCK_MONOTONIC
Definition: TimerService.h:33
enum edm::WallclockTimer::State state_
struct timeval startRealTime_
double WallclockTimer::stop ( )

Definition at line 81 of file WallclockTimer.cc.

References accumulatedRealTime_, calculateDeltaTime(), kRunning, kStopped, state_, and lumiQTWidget::t.

81  {
82  if(kRunning == state_) {
83  auto t = calculateDeltaTime();
85 
87  return t;
88  }
89  return 0.;
90 }
double calculateDeltaTime() const
enum edm::WallclockTimer::State state_

Member Data Documentation

double edm::WallclockTimer::accumulatedRealTime_
private

Definition at line 71 of file WallclockTimer.h.

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

struct timeval edm::WallclockTimer::startRealTime_
private

Definition at line 68 of file WallclockTimer.h.

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

enum edm::WallclockTimer::State edm::WallclockTimer::state_
private

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