|
Gaudi Framework, version v22r0 |
| Home | Generated: 9 Feb 2011 |
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local timer More...
#include <GaudiKernel/ChronoEntity.h>

Public Member Functions | |
| ChronoEntity () | |
| default constructor | |
| ~ChronoEntity () | |
| destructor | |
| IChronoSvc::ChronoStatus | start () |
| start the current chrono | |
| IChronoSvc::ChronoStatus | stop () |
| stop the chrono | |
| IChronoSvc::ChronoTime | delta (IChronoSvc::ChronoType type) const |
| return the last delta-time of type "type" | |
| IChronoSvc::ChronoStatus | status () const |
| return the status of chrono | |
| unsigned long | nOfMeasurements () const |
| number of chrono measurements | |
| double | uMinimalTime () const |
| minimal measurement for user time | |
| double | kMinimalTime () const |
| minimal measurement for kernel time | |
| double | eMinimalTime () const |
| minimal measurement for ellapsed time | |
| double | uMaximalTime () const |
| maximal measurement for user time | |
| double | kMaximalTime () const |
| maximal measurement for kernel time | |
| double | eMaximalTime () const |
| maximal measurement for ellapsed time | |
| double | uTotalTime () const |
| total user time | |
| double | kTotalTime () const |
| total Kernel time | |
| double | eTotalTime () const |
| total Elapsed time | |
| double | totalTime () const |
| total time | |
| double | kMeanTime () const |
| average Kernel Time | |
| double | uMeanTime () const |
| average User Time | |
| double | eMeanTime () const |
| average Elapsed Time | |
| double | kRMSTime () const |
| r.m.s Kernel Time | |
| double | uRMSTime () const |
| r.m.s User Time | |
| double | eRMSTime () const |
| r.m.s Elapsed Time | |
| double | kMeanErrorTime () const |
| error in mean Kernel time | |
| double | uMeanErrorTime () const |
| error in mean User time | |
| double | eMeanErrorTime () const |
| error in mean Elapsed time | |
| bool | operator< (const ChronoEntity &entity) const |
| comparison operator | |
| std::string | outputUserTime () const |
| print the chrono ; | |
| std::string | outputSystemTime () const |
| print the chrono ; | |
| std::string | outputElapsedTime () const |
| print the chrono ; | |
| std::string | outputUserTime (const std::string &fmt, System::TimeType unit) const |
| print the chrono according the format and units | |
| std::string | outputSystemTime (const std::string &fmt, System::TimeType unit) const |
| print the chrono according the format and units | |
| std::string | outputElapsedTime (const std::string &fmt, System::TimeType unit) const |
| print the chrono according the format and units | |
| std::string | outputTime (IChronoSvc::ChronoType typ, const std::string &fmt, System::TimeType unit) const |
| print the chrono according the format and units | |
Protected Member Functions | |
| std::string | format (const double total, const double minimal, const double mean, const double rms, const double maximal, const unsigned long number) const |
| format | |
Private Attributes | |
| IChronoSvc::ChronoStatus | m_status |
| current status of this chrono object; | |
| IChronoSvc::ChronoTime | m_delta_user |
| delta user time | |
| IChronoSvc::ChronoTime | m_delta_kernel |
| delta Kernel time | |
| IChronoSvc::ChronoTime | m_delta_elapsed |
| delta Elapsed time | |
| IChronoSvc::ChronoTime | m_start_user |
| start stamp for current measurement of user time | |
| IChronoSvc::ChronoTime | m_start_kernel |
| start stamp for current measurement of Kernel time | |
| IChronoSvc::ChronoTime | m_start_elapsed |
| start stamp for current measurement of Elapsed time | |
| StatEntity | m_user |
| the actual storage of "user" time | |
| StatEntity | m_kernel |
| the actual storage of "kernel" time | |
| StatEntity | m_elapsed |
| the actual storage of "elapsed" time | |
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local timer
Definition at line 23 of file ChronoEntity.h.
| ChronoEntity::ChronoEntity | ( | ) |
default constructor
current status of this chrono object;
Definition at line 50 of file ChronoEntity.cpp.
00052 : m_status ( IChronoSvc::UNKNOWN ) // current status 00054 , m_delta_user ( -1 ) // delta user time 00056 , m_delta_kernel ( -1 ) // delta kernel time 00058 , m_delta_elapsed ( -1 ) // delta elapsed time 00060 , m_start_user ( 0 ) // start for user 00062 , m_start_kernel ( 0 ) // start for kernel 00064 , m_start_elapsed ( 0 ) // start for elapsed 00065 {}
| ChronoEntity::~ChronoEntity | ( | ) | [inline] |
| IChronoSvc::ChronoTime ChronoEntity::delta | ( | IChronoSvc::ChronoType | type | ) | const [inline] |
return the last delta-time of type "type"
Definition at line 303 of file ChronoEntity.h.
00304 { 00305 const IChronoSvc::ChronoTime result = -1 ; 00306 switch ( type ) 00307 { 00308 case IChronoSvc::USER : return m_delta_user ; 00309 case IChronoSvc::KERNEL : return m_delta_kernel ; 00310 case IChronoSvc::ELAPSED : return m_delta_elapsed ; 00311 default : return result ; 00312 } 00313 // cannot reach this point 00314 }
| double ChronoEntity::eMaximalTime | ( | ) | const [inline] |
maximal measurement for ellapsed time
Definition at line 232 of file ChronoEntity.h.
00232 { return m_elapsed . flagMax () ; }
| double ChronoEntity::eMeanErrorTime | ( | ) | const [inline] |
error in mean Elapsed time
Definition at line 298 of file ChronoEntity.h.
00298 { return m_elapsed . flagMeanErr () ; }
| double ChronoEntity::eMeanTime | ( | ) | const [inline] |
average Elapsed Time
Definition at line 268 of file ChronoEntity.h.
00268 { return m_elapsed . flagMean () ; }
| double ChronoEntity::eMinimalTime | ( | ) | const [inline] |
minimal measurement for ellapsed time
Definition at line 217 of file ChronoEntity.h.
00217 { return m_elapsed. flagMin () ; }
| double ChronoEntity::eRMSTime | ( | ) | const [inline] |
r.m.s Elapsed Time
Definition at line 283 of file ChronoEntity.h.
00283 { return m_elapsed . flagRMS () ; }
| double ChronoEntity::eTotalTime | ( | ) | const [inline] |
total Elapsed time
Definition at line 247 of file ChronoEntity.h.
00247 { return m_elapsed . flag () ; }
| std::string ChronoEntity::format | ( | const double | total, | |
| const double | minimal, | |||
| const double | mean, | |||
| const double | rms, | |||
| const double | maximal, | |||
| const unsigned long | number | |||
| ) | const [protected] |
format
Definition at line 163 of file ChronoEntity.cpp.
00169 { 00171 const int buffer_size = 256 ; 00172 char buffer[buffer_size] ; 00173 int index = 0 ; 00175 long double unit = 1.0 ; 00176 std::string cunit = "" ; 00178 if ( total / microsecond < 500 ) 00179 { unit = microsecond ; cunit = " [us]" ; } 00180 else if( total / millisecond < 500 ) 00181 { unit = millisecond ; cunit = " [ms]" ; } 00182 else if( total / second < 500 ) 00183 { unit = second ; cunit = " [s]" ; } 00184 else if( total / minute < 500 ) 00185 { unit = minute ; cunit = "[min]" ; } 00186 else if( total / hour < 500 ) 00187 { unit = hour ; cunit = " [h]" ; } 00188 else if( total / day < 10 ) 00189 { unit = day ; cunit = "[day]" ; } 00190 else if( total / week < 5 ) 00191 { unit = week ; cunit = " [w]" ; } 00192 else if( total / month < 20 ) 00193 { unit = month ; cunit = "[mon]" ; } 00194 else 00195 { unit = year ; cunit = " [y]" ; } 00197 index += sprintf( buffer + index , "Tot=%5.3g" , (double) (total / unit) ) ; 00198 index += sprintf( buffer + index , "%s" , cunit.c_str() ) ; 00200 if( 1 < number ) 00201 { 00202 00203 if ( mean / microsecond < 500 ) 00204 { unit = microsecond ; cunit = " [us]" ; } 00205 else if( mean / millisecond < 500 ) 00206 { unit = millisecond ; cunit = " [ms]" ; } 00207 else if( mean / second < 500 ) 00208 { unit = second ; cunit = " [s]" ; } 00209 else if( mean / minute < 500 ) 00210 { unit = minute ; cunit = "[min]" ; } 00211 else if( mean / hour < 500 ) 00212 { unit = hour ; cunit = " [h]" ; } 00213 else if( mean / day < 10 ) 00214 { unit = day ; cunit = "[day]" ; } 00215 else if( mean / week < 5 ) 00216 { unit = week ; cunit = " [w]" ; } 00217 else if( mean / month < 20 ) 00218 { unit = month ; cunit = "[mon]" ; } 00219 else 00220 { unit = year ; cunit = "[year]" ; } 00222 index += 00223 sprintf( buffer + index , 00224 " Ave/Min/Max=%5.3g" , (double) ( mean / unit ) ) ; 00225 index += 00226 sprintf( buffer + index , 00227 "(+-%5.3g)" , (double) ( rms / unit ) ) ; 00228 index += 00229 sprintf( buffer + index , 00230 "/%5.3g" , (double) ( minimal / unit ) ) ; 00231 index += 00232 sprintf( buffer + index , 00233 "/%5.3g" , (double) ( maximal / unit ) ) ; 00235 index += sprintf( buffer + index , "%s" , cunit.c_str() ); 00237 } 00238 else 00239 { index += sprintf( buffer + index , "%44s" , " " ); } 00241 index += sprintf( buffer + index , " #=%3lu" , number ); 00243 return std::string( buffer, 0 , index ); 00245 }
| double ChronoEntity::kMaximalTime | ( | ) | const [inline] |
maximal measurement for kernel time
Definition at line 227 of file ChronoEntity.h.
00227 { return m_kernel . flagMax () ; }
| double ChronoEntity::kMeanErrorTime | ( | ) | const [inline] |
error in mean Kernel time
Definition at line 288 of file ChronoEntity.h.
00288 { return m_kernel . flagMeanErr () ; }
| double ChronoEntity::kMeanTime | ( | ) | const [inline] |
average Kernel Time
Definition at line 258 of file ChronoEntity.h.
00258 { return m_kernel . flagMean () ; }
| double ChronoEntity::kMinimalTime | ( | ) | const [inline] |
minimal measurement for kernel time
Definition at line 212 of file ChronoEntity.h.
00212 { return m_kernel . flagMin () ; }
| double ChronoEntity::kRMSTime | ( | ) | const [inline] |
r.m.s Kernel Time
Definition at line 273 of file ChronoEntity.h.
00273 { return m_kernel . flagRMS () ; }
| double ChronoEntity::kTotalTime | ( | ) | const [inline] |
total Kernel time
Definition at line 242 of file ChronoEntity.h.
00242 { return m_kernel . flag () ; }
| unsigned long ChronoEntity::nOfMeasurements | ( | ) | const [inline] |
number of chrono measurements
Definition at line 202 of file ChronoEntity.h.
00202 { return m_user . nEntries() ; }
| bool ChronoEntity::operator< | ( | const ChronoEntity & | entity | ) | const |
comparison operator
Definition at line 249 of file ChronoEntity.cpp.
00250 { 00251 return 00252 ( &e == this ) ? false : 00253 ( totalTime () < e.totalTime () ) ? true : 00254 ( totalTime () > e.totalTime () ) ? false : 00255 ( m_user < e.m_user ) ? true : 00256 ( e.m_user < m_user ) ? false : 00257 ( m_kernel < e.m_kernel ) ? true : 00258 ( e.m_kernel < m_kernel ) ? false : 00259 ( m_elapsed < e.m_elapsed ) ? true : 00260 ( e.m_elapsed < m_elapsed ) ? false : false ; 00261 }
| std::string ChronoEntity::outputElapsedTime | ( | const std::string & | fmt, | |
| System::TimeType | unit | |||
| ) | const [inline] |
print the chrono according the format and units
| fmt | the format string | |
| unit | the unit |
Definition at line 355 of file ChronoEntity.h.
00357 { 00358 return outputTime ( IChronoSvc::ELAPSED , fmt , unit ) ; 00359 }
| std::string ChronoEntity::outputElapsedTime | ( | ) | const |
print the chrono ;
Definition at line 148 of file ChronoEntity.cpp.
00149 { 00150 std::string res ("TimeElapsed: ") ; 00151 return res += format 00152 ( eTotalTime () , 00153 eMinimalTime () , 00154 eMeanTime () , 00155 eRMSTime () , 00156 eMaximalTime () , 00157 nOfMeasurements() ); 00158 }
| std::string ChronoEntity::outputSystemTime | ( | const std::string & | fmt, | |
| System::TimeType | unit | |||
| ) | const [inline] |
print the chrono according the format and units
| fmt | the format string | |
| unit | the unit |
Definition at line 340 of file ChronoEntity.h.
00342 { 00343 return outputTime ( IChronoSvc::KERNEL , fmt , unit ) ; 00344 }
| std::string ChronoEntity::outputSystemTime | ( | ) | const |
print the chrono ;
Definition at line 135 of file ChronoEntity.cpp.
00136 { 00137 std::string res ("Time System : ") ; 00138 return res += format 00139 ( kTotalTime () , 00140 kMinimalTime () , 00141 kMeanTime () , 00142 kRMSTime () , 00143 kMaximalTime () , 00144 nOfMeasurements() ); 00145 }
| std::string ChronoEntity::outputTime | ( | IChronoSvc::ChronoType | typ, | |
| const std::string & | fmt, | |||
| System::TimeType | unit | |||
| ) | const |
print the chrono according the format and units
The format fields are:
| typ | the chrono type | |
| fmt | the format string | |
| unit | the unit |
Definition at line 272 of file ChronoEntity.cpp.
00275 { 00276 boost::format _fmt ( fmt ) ; 00277 // allow various number of arguments 00278 using namespace boost::io ; 00279 _fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ; 00280 // 00281 double _unit = microsecond ; 00282 switch ( unit ) 00283 { 00284 case System::Year : _unit = year ; break ; 00285 case System::Month : _unit = month ; break ; 00286 case System::Day : _unit = day ; break ; 00287 case System::Hour : _unit = hour ; break ; 00288 case System::Min : _unit = minute ; break ; 00289 case System::Sec : _unit = second ; break ; 00290 case System::milliSec : _unit = millisecond ; break ; 00291 case System::microSec : _unit = microsecond ; break ; 00292 case System::nanoSec : _unit = nanosecond ; break ; 00293 default : _unit = microsecond ; break ; 00294 } 00295 // 00296 const StatEntity* stat = &m_user; 00297 switch ( typ ) 00298 { 00299 case IChronoSvc::USER : stat = &m_user ; break ; 00300 case IChronoSvc::KERNEL : stat = &m_kernel ; break ; 00301 case IChronoSvc::ELAPSED : stat = &m_elapsed ; break ; 00302 default : stat = &m_user ; break ; 00303 } 00304 // 00305 _fmt 00306 % ( stat -> nEntries () ) // %1 : #entries 00307 % ( stat -> flag () / _unit ) // %2 : total time 00308 % ( stat -> flagMean () / _unit ) // %3 : mean time 00309 % ( stat -> flagRMS () / _unit ) // %4 : RMS time 00310 % ( stat -> flagMeanErr () / _unit ) // %5 : error in mean time 00311 % ( stat -> flagMin () / _unit ) // %6 : minimal time 00312 % ( stat -> flagMax () / _unit ) ; // %7 : maximal time 00313 // 00314 return _fmt.str() ; 00315 }
| std::string ChronoEntity::outputUserTime | ( | const std::string & | fmt, | |
| System::TimeType | unit | |||
| ) | const [inline] |
print the chrono according the format and units
| fmt | the format string | |
| unit | the unit |
Definition at line 325 of file ChronoEntity.h.
00327 { 00328 return outputTime ( IChronoSvc::USER , fmt , unit ) ; 00329 }
| std::string ChronoEntity::outputUserTime | ( | ) | const |
print the chrono ;
Definition at line 121 of file ChronoEntity.cpp.
00122 { 00123 std::string res ("Time User : ") ; 00124 return res += format 00125 ( uTotalTime () , 00126 uMinimalTime () , 00127 uMeanTime () , 00128 uRMSTime () , 00129 uMaximalTime () , 00130 nOfMeasurements() ); 00131 }
| IChronoSvc::ChronoStatus ChronoEntity::start | ( | ) |
start the current chrono
Definition at line 74 of file ChronoEntity.cpp.
00075 { 00076 if ( IChronoSvc::RUNNING == m_status ) { return m_status ; } 00077 // 00078 // following lines could be platform dependent! 00079 // 00080 // Store in object the measured times 00081 m_start_user = static_cast<IChronoSvc::ChronoTime>(System::userTime ( MyUnit )); 00082 m_start_kernel = static_cast<IChronoSvc::ChronoTime>(System::kernelTime ( MyUnit )); 00083 m_start_elapsed = static_cast<IChronoSvc::ChronoTime>(System::ellapsedTime ( MyUnit )); 00085 m_status = IChronoSvc::RUNNING; 00087 return m_status ; 00088 }
| IChronoSvc::ChronoStatus ChronoEntity::status | ( | ) | const [inline] |
return the status of chrono
Definition at line 197 of file ChronoEntity.h.
00197 { return m_status; }
| IChronoSvc::ChronoStatus ChronoEntity::stop | ( | ) |
stop the chrono
Definition at line 96 of file ChronoEntity.cpp.
00097 { 00098 if ( IChronoSvc::RUNNING != m_status ) { return m_status ; } 00099 00100 // following lines could be platform dependent! 00101 00102 m_delta_user = System::userTime ( MyUnit ) - m_start_user ; 00103 m_delta_kernel = System::kernelTime ( MyUnit ) - m_start_kernel ; 00104 m_delta_elapsed = System::ellapsedTime ( MyUnit ) - m_start_elapsed ; 00105 00106 // update the counters: 00107 00108 m_user += m_delta_user ; 00109 m_kernel += m_delta_kernel ; 00110 m_elapsed += m_delta_elapsed ; 00111 00112 // set new status 00113 00114 m_status = IChronoSvc::STOPPED; 00115 00116 return m_status ; 00117 }
| double ChronoEntity::totalTime | ( | ) | const [inline] |
total time
Definition at line 252 of file ChronoEntity.h.
00253 { return uTotalTime() + kTotalTime() ; }
| double ChronoEntity::uMaximalTime | ( | ) | const [inline] |
maximal measurement for user time
Definition at line 222 of file ChronoEntity.h.
00222 { return m_user . flagMax () ; }
| double ChronoEntity::uMeanErrorTime | ( | ) | const [inline] |
error in mean User time
Definition at line 293 of file ChronoEntity.h.
00293 { return m_user . flagMeanErr () ; }
| double ChronoEntity::uMeanTime | ( | ) | const [inline] |
average User Time
Definition at line 263 of file ChronoEntity.h.
00263 { return m_user . flagMean () ; }
| double ChronoEntity::uMinimalTime | ( | ) | const [inline] |
minimal measurement for user time
Definition at line 206 of file ChronoEntity.h.
00207 { return m_user . flagMin () ; }
| double ChronoEntity::uRMSTime | ( | ) | const [inline] |
r.m.s User Time
Definition at line 278 of file ChronoEntity.h.
00278 { return m_user . flagRMS () ; }
| double ChronoEntity::uTotalTime | ( | ) | const [inline] |
delta Elapsed time
Definition at line 178 of file ChronoEntity.h.
delta Kernel time
Definition at line 176 of file ChronoEntity.h.
delta user time
Definition at line 174 of file ChronoEntity.h.
StatEntity ChronoEntity::m_elapsed [private] |
the actual storage of "elapsed" time
Definition at line 190 of file ChronoEntity.h.
StatEntity ChronoEntity::m_kernel [private] |
the actual storage of "kernel" time
Definition at line 188 of file ChronoEntity.h.
start stamp for current measurement of Elapsed time
Definition at line 184 of file ChronoEntity.h.
start stamp for current measurement of Kernel time
Definition at line 182 of file ChronoEntity.h.
start stamp for current measurement of user time
Definition at line 180 of file ChronoEntity.h.
current status of this chrono object;
Definition at line 172 of file ChronoEntity.h.
StatEntity ChronoEntity::m_user [private] |
the actual storage of "user" time
Definition at line 186 of file ChronoEntity.h.