BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTimer Class Reference

#include <BesTimer.h>

Public Member Functions

 BesTimer (const std::string name)
 
std::string & name ()
 
float elapsed (void) const
 
double mean (void) const
 
double rms (void) const
 
int number_of_measurements (void) const
 
void propName (std::string name)
 
std::string & propName ()
 
unsigned int propVal ()
 
void propVal (unsigned int val)
 
double meanPropVal ()
 
double meanTimePerObject ()
 
bool operator< (BesTimer &it)
 
void start (void)
 
void stop (void)
 
void pause (void)
 
void resume (void)
 
void reset ()
 
 BesTimer (const std::string name)
 
std::string & name ()
 
float elapsed (void) const
 
double mean (void) const
 
double rms (void) const
 
int number_of_measurements (void) const
 
void propName (std::string name)
 
std::string & propName ()
 
unsigned int propVal ()
 
void propVal (unsigned int val)
 
double meanPropVal ()
 
double meanTimePerObject ()
 
bool operator< (BesTimer &it)
 
void start (void)
 
void stop (void)
 
void pause (void)
 
void resume (void)
 
void reset ()
 

Detailed Description

Constructor & Destructor Documentation

◆ BesTimer() [1/2]

BesTimer::BesTimer ( const std::string  name)

Definition at line 13 of file BesTimer.cxx.

14 : m_name (name) {
15 m_numberOfMeasurements = 0;
16 m_mean = 0.0;
17 m_ms = 0.0;
18 m_elapsed = 0.0;
19 m_started=false;
20 m_paused=false;
21 m_propVal = 0;
22 m_meanVal = 0;
23 m_meanTimePerObject = 0.0;
24 m_NmeanTimePerObject = 0;
25 }

◆ BesTimer() [2/2]

BesTimer::BesTimer ( const std::string  name)

Member Function Documentation

◆ elapsed() [1/2]

float BesTimer::elapsed ( void  ) const
inline

Definition at line 23 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

23{ return (m_started? 0.0 : m_elapsed);}

Referenced by MixerAlg::execute(), MagFieldReader::execute(), MdcFastTrkAlg::execute(), and MixerAlg::nextEvent().

◆ elapsed() [2/2]

float BesTimer::elapsed ( void  ) const
inline

Definition at line 23 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

23{ return (m_started? 0.0 : m_elapsed);}

◆ mean() [1/2]

double BesTimer::mean ( void  ) const
inline

Definition at line 25 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

25{ return m_mean;}

◆ mean() [2/2]

double BesTimer::mean ( void  ) const
inline

Definition at line 25 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

25{ return m_mean;}

◆ meanPropVal() [1/2]

double BesTimer::meanPropVal ( )
inline

Definition at line 40 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

40{ return m_meanVal;}

◆ meanPropVal() [2/2]

double BesTimer::meanPropVal ( )
inline

Definition at line 40 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

40{ return m_meanVal;}

◆ meanTimePerObject() [1/2]

double BesTimer::meanTimePerObject ( )
inline

Definition at line 41 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

41{ return m_meanTimePerObject;}

◆ meanTimePerObject() [2/2]

double BesTimer::meanTimePerObject ( )
inline

Definition at line 41 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

41{ return m_meanTimePerObject;}

◆ name() [1/2]

std::string & BesTimer::name ( )
inline

Definition at line 21 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

21{ return m_name; }

Referenced by operator<(), and propName().

◆ name() [2/2]

std::string & BesTimer::name ( )
inline

Definition at line 21 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

21{ return m_name; }

◆ number_of_measurements() [1/2]

int BesTimer::number_of_measurements ( void  ) const
inline

Definition at line 31 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

31{ return m_numberOfMeasurements;}

◆ number_of_measurements() [2/2]

int BesTimer::number_of_measurements ( void  ) const
inline

Definition at line 31 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

31{ return m_numberOfMeasurements;}

◆ operator<() [1/2]

bool BesTimer::operator< ( BesTimer it)
inline

Definition at line 44 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

44{ return (this->name() < it.name());}

◆ operator<() [2/2]

bool BesTimer::operator< ( BesTimer it)
inline

Definition at line 44 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

44{ return (this->name() < it.name());}

◆ pause() [1/2]

void BesTimer::pause ( void  )

Definition at line 80 of file BesTimer.cxx.

80 {
81 struct timeval tv;
82
83 // only pause if started
84 // a pause while paused is ignored
85 if (m_paused || !m_started) return;
86 m_paused = true;
87 gettimeofday(&tv, 0);
88
89 float mtime;
90 int secs, usecs;
91
92 if (tv.tv_sec >= m_startTime.tv_sec) {
93 secs = tv.tv_sec - m_startTime.tv_sec;
94 } else {
95 secs = tv.tv_sec - m_startTime.tv_sec + SecsInDay;
96 }
97 usecs = tv.tv_usec - m_startTime.tv_usec;
98 mtime = static_cast<float>(secs)*1000. + static_cast<float>(usecs)/1000.;
99 m_elapsed += mtime; // time so far
100 }
#define SecsInDay
Definition: BesTimer.cxx:11

◆ pause() [2/2]

void BesTimer::pause ( void  )

◆ propName() [1/4]

std::string & BesTimer::propName ( )
inline

Definition at line 35 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

35{ return m_propName; }

◆ propName() [2/4]

std::string & BesTimer::propName ( )
inline

Definition at line 35 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

35{ return m_propName; }

◆ propName() [3/4]

void BesTimer::propName ( std::string  name)
inline

Definition at line 34 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

34{ m_propName = name; }

Referenced by MdcFastTrkAlg::initialize(), and TrkReco::initialize().

◆ propName() [4/4]

void BesTimer::propName ( std::string  name)
inline

Definition at line 34 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

34{ m_propName = name; }

◆ propVal() [1/4]

unsigned int BesTimer::propVal ( )
inline

Definition at line 37 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

37{ return m_propVal;}

◆ propVal() [2/4]

unsigned int BesTimer::propVal ( )
inline

Definition at line 37 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

37{ return m_propVal;}

◆ propVal() [3/4]

void BesTimer::propVal ( unsigned int  val)
inline

Definition at line 38 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

38{ m_propVal = val; }

◆ propVal() [4/4]

void BesTimer::propVal ( unsigned int  val)
inline

Definition at line 38 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

38{ m_propVal = val; }

◆ reset() [1/2]

void BesTimer::reset ( )

Definition at line 114 of file BesTimer.cxx.

114 {
115 if (!m_started) {
116 m_elapsed = 0.0;
117 m_propVal = 0;
118 }
119 }

◆ reset() [2/2]

void BesTimer::reset ( )

◆ resume() [1/2]

void BesTimer::resume ( void  )

Definition at line 102 of file BesTimer.cxx.

102 {
103 struct timeval tv;
104
105 if (!m_started) {
106 start(); // resume acts as start if not started
107 } else if (m_paused) {
108 m_paused = false;
109 gettimeofday(&tv, 0);
110 m_startTime = tv;
111 }
112 }
void start(void)
Definition: BesTimer.cxx:27

◆ resume() [2/2]

void BesTimer::resume ( void  )

◆ rms() [1/2]

double BesTimer::rms ( void  ) const
inline

Definition at line 26 of file InstallArea/include/BesTimerSvc/BesTimerSvc/BesTimer.h.

26 {
27 double var = m_ms - m_mean*m_mean;
28 return (var > 0 ? sqrt(var) : 0.0);
29 }

◆ rms() [2/2]

double BesTimer::rms ( void  ) const
inline

Definition at line 26 of file Utilities/BesTimerSvc/BesTimerSvc-00-00-12/BesTimerSvc/BesTimer.h.

26 {
27 double var = m_ms - m_mean*m_mean;
28 return (var > 0 ? sqrt(var) : 0.0);
29 }

◆ start() [1/2]

void BesTimer::start ( void  )

Definition at line 27 of file BesTimer.cxx.

27 {
28 struct timeval tv;
29
30 m_started = true;
31 m_paused = false;
32 m_elapsed = 0.0;
33 m_propVal = 0;
34 // if already started, the start time will be over-written
35 gettimeofday(&tv, 0);
36 m_startTime = tv;
37 }

Referenced by MixerAlg::execute(), MagFieldReader::execute(), MdcFastTrkAlg::execute(), TrkReco::execute(), MixerAlg::nextEvent(), and resume().

◆ start() [2/2]

void BesTimer::start ( void  )

◆ stop() [1/2]

void BesTimer::stop ( void  )

Definition at line 39 of file BesTimer.cxx.

39 {
40 struct timeval tv;
41
42 if (!m_started) return;
43
44 gettimeofday(&tv, 0);
45 m_started = false;
46
47 if (!m_paused) {
48 float mtime;
49 int secs, usecs;
50
51 if (tv.tv_sec >= m_startTime.tv_sec) {
52 secs = tv.tv_sec - m_startTime.tv_sec;
53 } else {
54 secs = tv.tv_sec - m_startTime.tv_sec + SecsInDay;
55 }
56 usecs = tv.tv_usec - m_startTime.tv_usec;
57 mtime = static_cast<float>(secs)*1000. + static_cast<float>(usecs)/1000.;
58
59 // elapsed time
60 m_elapsed += mtime;
61
62 }
63
64 // statistics - mean, rms
65 double denom = static_cast <double> (++m_numberOfMeasurements);
66 double d = m_elapsed - m_mean;
67 m_mean += d / denom;
68 double dd = m_elapsed*m_elapsed - m_ms;
69 m_ms += dd / denom;
70
71 // mean property
72 m_meanVal += static_cast <double> (m_propVal - m_meanVal) / denom;
73 if (m_propVal !=0) {
74 double timePerObject = m_elapsed/static_cast <double>(m_propVal);
75 m_meanTimePerObject += static_cast <double> (timePerObject - m_meanTimePerObject) /
76 static_cast<double> (++m_NmeanTimePerObject);
77 }
78 }
double m_mean

Referenced by MixerAlg::execute(), MagFieldReader::execute(), MdcFastTrkAlg::execute(), and MixerAlg::nextEvent().

◆ stop() [2/2]

void BesTimer::stop ( void  )

The documentation for this class was generated from the following files: