#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 () |
Private Attributes | |
std::string | m_name |
timeval | m_startTime |
float | m_elapsed |
double | m_mean |
double | m_ms |
int | m_numberOfMeasurements |
bool | m_started |
bool | m_paused |
std::string | m_propName |
unsigned int | m_propVal |
double | m_meanVal |
double | m_meanTimePerObject |
int | m_NmeanTimePerObject |
Definition at line 13 of file BesTimer.h.
BesTimer::BesTimer | ( | const std::string | name | ) |
Definition at line 13 of file BesTimer.cxx.
References m_elapsed, m_mean, m_meanTimePerObject, m_meanVal, m_ms, m_NmeanTimePerObject, m_numberOfMeasurements, m_paused, m_propVal, and m_started.
00014 : m_name (name) { 00015 m_numberOfMeasurements = 0; 00016 m_mean = 0.0; 00017 m_ms = 0.0; 00018 m_elapsed = 0.0; 00019 m_started=false; 00020 m_paused=false; 00021 m_propVal = 0; 00022 m_meanVal = 0; 00023 m_meanTimePerObject = 0.0; 00024 m_NmeanTimePerObject = 0; 00025 }
float BesTimer::elapsed | ( | void | ) | const [inline] |
Definition at line 23 of file BesTimer.h.
References m_elapsed, and m_started.
Referenced by MixerAlg::execute(), MdcFastTrkAlg::execute(), MagFieldReader::execute(), TrkReco::FillTuple(), and MixerAlg::nextEvent().
double BesTimer::mean | ( | void | ) | const [inline] |
double BesTimer::meanPropVal | ( | ) | [inline] |
double BesTimer::meanTimePerObject | ( | ) | [inline] |
Definition at line 41 of file BesTimer.h.
References m_meanTimePerObject.
00041 { return m_meanTimePerObject;}
std::string& BesTimer::name | ( | void | ) | [inline] |
Definition at line 21 of file BesTimer.h.
References m_name.
Referenced by operator<().
00021 { return m_name; }
int BesTimer::number_of_measurements | ( | void | ) | const [inline] |
Definition at line 31 of file BesTimer.h.
References m_numberOfMeasurements.
00031 { return m_numberOfMeasurements;}
Definition at line 44 of file BesTimer.h.
References name().
00044 { return (this->name() < it.name());}
void BesTimer::pause | ( | void | ) |
Definition at line 80 of file BesTimer.cxx.
References m_elapsed, m_paused, m_started, m_startTime, and SecsInDay.
00080 { 00081 struct timeval tv; 00082 00083 // only pause if started 00084 // a pause while paused is ignored 00085 if (m_paused || !m_started) return; 00086 m_paused = true; 00087 gettimeofday(&tv, 0); 00088 00089 float mtime; 00090 int secs, usecs; 00091 00092 if (tv.tv_sec >= m_startTime.tv_sec) { 00093 secs = tv.tv_sec - m_startTime.tv_sec; 00094 } else { 00095 secs = tv.tv_sec - m_startTime.tv_sec + SecsInDay; 00096 } 00097 usecs = tv.tv_usec - m_startTime.tv_usec; 00098 mtime = static_cast<float>(secs)*1000. + static_cast<float>(usecs)/1000.; 00099 m_elapsed += mtime; // time so far 00100 }
std::string& BesTimer::propName | ( | ) | [inline] |
void BesTimer::propName | ( | std::string | name | ) | [inline] |
Definition at line 34 of file BesTimer.h.
References m_propName.
Referenced by TrkReco::initialize(), and MdcFastTrkAlg::initialize().
00034 { m_propName = name; }
void BesTimer::propVal | ( | unsigned int | val | ) | [inline] |
unsigned int BesTimer::propVal | ( | ) | [inline] |
void BesTimer::reset | ( | ) |
void BesTimer::resume | ( | void | ) |
Definition at line 102 of file BesTimer.cxx.
References m_paused, m_started, m_startTime, and start().
00102 { 00103 struct timeval tv; 00104 00105 if (!m_started) { 00106 start(); // resume acts as start if not started 00107 } else if (m_paused) { 00108 m_paused = false; 00109 gettimeofday(&tv, 0); 00110 m_startTime = tv; 00111 } 00112 }
double BesTimer::rms | ( | void | ) | const [inline] |
void BesTimer::start | ( | void | ) |
Definition at line 27 of file BesTimer.cxx.
References m_elapsed, m_paused, m_propVal, m_started, and m_startTime.
Referenced by MixerAlg::execute(), TrkReco::execute(), MdcFastTrkAlg::execute(), MagFieldReader::execute(), MixerAlg::nextEvent(), and resume().
00027 { 00028 struct timeval tv; 00029 00030 m_started = true; 00031 m_paused = false; 00032 m_elapsed = 0.0; 00033 m_propVal = 0; 00034 // if already started, the start time will be over-written 00035 gettimeofday(&tv, 0); 00036 m_startTime = tv; 00037 }
void BesTimer::stop | ( | void | ) |
Definition at line 39 of file BesTimer.cxx.
References m_elapsed, m_mean, m_meanTimePerObject, m_meanVal, m_ms, m_NmeanTimePerObject, m_numberOfMeasurements, m_paused, m_propVal, m_started, m_startTime, and SecsInDay.
Referenced by MixerAlg::execute(), MdcFastTrkAlg::execute(), MagFieldReader::execute(), TrkReco::FillTuple(), and MixerAlg::nextEvent().
00039 { 00040 struct timeval tv; 00041 00042 if (!m_started) return; 00043 00044 gettimeofday(&tv, 0); 00045 m_started = false; 00046 00047 if (!m_paused) { 00048 float mtime; 00049 int secs, usecs; 00050 00051 if (tv.tv_sec >= m_startTime.tv_sec) { 00052 secs = tv.tv_sec - m_startTime.tv_sec; 00053 } else { 00054 secs = tv.tv_sec - m_startTime.tv_sec + SecsInDay; 00055 } 00056 usecs = tv.tv_usec - m_startTime.tv_usec; 00057 mtime = static_cast<float>(secs)*1000. + static_cast<float>(usecs)/1000.; 00058 00059 // elapsed time 00060 m_elapsed += mtime; 00061 00062 } 00063 00064 // statistics - mean, rms 00065 double denom = static_cast <double> (++m_numberOfMeasurements); 00066 double d = m_elapsed - m_mean; 00067 m_mean += d / denom; 00068 double dd = m_elapsed*m_elapsed - m_ms; 00069 m_ms += dd / denom; 00070 00071 // mean property 00072 m_meanVal += static_cast <double> (m_propVal - m_meanVal) / denom; 00073 if (m_propVal !=0) { 00074 double timePerObject = m_elapsed/static_cast <double>(m_propVal); 00075 m_meanTimePerObject += static_cast <double> (timePerObject - m_meanTimePerObject) / 00076 static_cast<double> (++m_NmeanTimePerObject); 00077 } 00078 }
float BesTimer::m_elapsed [private] |
Definition at line 57 of file BesTimer.h.
Referenced by BesTimer(), elapsed(), pause(), reset(), start(), and stop().
double BesTimer::m_mean [private] |
double BesTimer::m_meanTimePerObject [private] |
Definition at line 66 of file BesTimer.h.
Referenced by BesTimer(), meanTimePerObject(), and stop().
double BesTimer::m_meanVal [private] |
double BesTimer::m_ms [private] |
std::string BesTimer::m_name [private] |
int BesTimer::m_NmeanTimePerObject [private] |
int BesTimer::m_numberOfMeasurements [private] |
Definition at line 60 of file BesTimer.h.
Referenced by BesTimer(), number_of_measurements(), and stop().
bool BesTimer::m_paused [private] |
Definition at line 62 of file BesTimer.h.
Referenced by BesTimer(), pause(), resume(), start(), and stop().
std::string BesTimer::m_propName [private] |
unsigned int BesTimer::m_propVal [private] |
Definition at line 64 of file BesTimer.h.
Referenced by BesTimer(), propVal(), reset(), start(), and stop().
bool BesTimer::m_started [private] |
Definition at line 61 of file BesTimer.h.
Referenced by BesTimer(), elapsed(), pause(), reset(), resume(), start(), and stop().
struct timeval BesTimer::m_startTime [private] |