|
Gaudi Framework, version v23r4 |
| Home | Generated: Mon Sep 17 2012 |
00001 #ifndef GAUDIKERNEL_CHRONOENTITY_H 00002 #define GAUDIKERNEL_CHRONOENTITY_H 1 00003 // ============================================================================ 00004 // Include files 00005 // ============================================================================ 00006 // GaudiKernel 00007 // ============================================================================ 00008 #include "GaudiKernel/IChronoSvc.h" 00009 #include "GaudiKernel/StatEntity.h" 00010 #include "GaudiKernel/Timing.h" 00011 // ============================================================================ 00021 class GAUDI_API ChronoEntity 00022 { 00023 public: 00025 ChronoEntity(); 00027 ~ChronoEntity(){} 00029 public: 00030 // ========================================================================== 00031 // The basic Chrono Operations 00032 // ========================================================================== 00034 IChronoSvc::ChronoStatus start() ; 00036 IChronoSvc::ChronoStatus stop () ; 00037 // ========================================================================== 00039 inline IChronoSvc::ChronoTime delta ( IChronoSvc::ChronoType type ) const ; 00041 inline IChronoSvc::ChronoStatus status() const ; 00042 // ========================================================================== 00043 public: 00044 // ========================================================== 00045 // Access to Chrono Statistics 00046 // ========================================================== 00048 inline unsigned long nOfMeasurements () const ; 00049 // ========================================================== 00051 inline double uMinimalTime () const ; 00053 inline double kMinimalTime () const ; 00055 inline double eMinimalTime () const ; 00057 inline double uMaximalTime () const ; 00059 inline double kMaximalTime () const ; 00061 inline double eMaximalTime () const ; 00063 inline double uTotalTime () const ; 00065 inline double kTotalTime () const ; 00067 inline double eTotalTime () const ; 00069 inline double totalTime () const ; 00071 inline double kMeanTime () const ; 00073 inline double uMeanTime () const ; 00075 inline double eMeanTime () const ; 00077 inline double kRMSTime () const ; 00079 inline double uRMSTime () const ; 00081 inline double eRMSTime () const ; 00083 inline double kMeanErrorTime () const ; 00085 inline double uMeanErrorTime () const ; 00087 inline double eMeanErrorTime () const ; 00088 // ========================================================================== 00089 public: 00090 // ========================================================================== 00092 bool operator<( const ChronoEntity& entity ) const; 00093 // ========================================================================== 00094 public: 00095 // ========================================================================== 00097 std::string outputUserTime () const ; 00099 std::string outputSystemTime () const ; 00101 std::string outputElapsedTime () const ; 00102 // ========================================================================== 00103 public: 00104 // ========================================================================== 00111 inline std::string outputUserTime 00112 ( const std::string& fmt , 00113 System::TimeType unit ) const ; 00120 inline std::string outputSystemTime 00121 ( const std::string& fmt , 00122 System::TimeType unit ) const ; 00129 inline std::string outputElapsedTime 00130 ( const std::string& fmt , 00131 System::TimeType unit ) const ; 00132 // ========================================================================== 00151 std::string outputTime 00152 ( IChronoSvc::ChronoType typ , 00153 const std::string& fmt , 00154 System::TimeType unit ) const ; 00155 // ========================================================================== 00156 protected: 00157 // ========================================================================== 00159 std::string format 00160 ( const double total , 00161 const double minimal , 00162 const double mean , 00163 const double rms , 00164 const double maximal , 00165 const unsigned long number ) const ; 00166 // ========================================================================== 00167 private: 00168 // ========================================================================== 00170 IChronoSvc::ChronoStatus m_status ; 00172 System::ProcessTime m_delta; 00174 System::ProcessTime m_start; 00176 StatEntity m_user ; // the actual storage of "user" time 00178 StatEntity m_kernel ; // the actual storage of "kernel" time 00180 StatEntity m_elapsed ; // the actual storage of "elapsed" time 00182 static const System::TimeType TimeUnit = System::microSec; 00183 // ========================================================================== 00184 }; 00185 // ============================================================================ 00186 // return the status of chrono 00187 // ============================================================================ 00188 inline IChronoSvc::ChronoStatus 00189 ChronoEntity::status() const { return m_status; } 00190 // ============================================================================ 00191 // number of chrono measurements 00192 // ============================================================================ 00193 inline unsigned long 00194 ChronoEntity::nOfMeasurements () const { return m_user . nEntries() ; } 00195 // ============================================================================ 00196 // minimal measurement for user time 00197 // ============================================================================ 00198 inline double ChronoEntity::uMinimalTime () const 00199 { return m_user . flagMin () ; } 00200 // ============================================================================ 00201 // minimal measurement for kernel time 00202 // ============================================================================ 00203 inline double 00204 ChronoEntity::kMinimalTime () const { return m_kernel . flagMin () ; } 00205 // ============================================================================ 00206 // minimal measurement for elapsed time 00207 // ============================================================================ 00208 inline double 00209 ChronoEntity::eMinimalTime () const { return m_elapsed. flagMin () ; } 00210 // ============================================================================ 00211 // maximal measurement for user time 00212 // ============================================================================ 00213 inline double 00214 ChronoEntity::uMaximalTime () const { return m_user . flagMax () ; } 00215 // ============================================================================ 00216 // maximal measurement for kernel time 00217 // ============================================================================ 00218 inline double 00219 ChronoEntity::kMaximalTime () const { return m_kernel . flagMax () ; } 00220 // ============================================================================ 00221 // maximal measurement for ellapsed time 00222 // ============================================================================ 00223 inline double 00224 ChronoEntity::eMaximalTime () const { return m_elapsed . flagMax () ; } 00225 // ============================================================================ 00226 // total user time 00227 // ============================================================================ 00228 inline double 00229 ChronoEntity::uTotalTime () const { return m_user . flag () ; } 00230 // ============================================================================ 00231 // total Kernel time 00232 // ============================================================================ 00233 inline double 00234 ChronoEntity::kTotalTime () const { return m_kernel . flag () ; } 00235 // ============================================================================ 00236 // total Elapsed time 00237 // ============================================================================ 00238 inline double 00239 ChronoEntity::eTotalTime () const { return m_elapsed . flag () ; } 00240 // ============================================================================ 00241 // total time 00242 // ============================================================================ 00243 inline double 00244 ChronoEntity::totalTime () const 00245 { return uTotalTime() + kTotalTime() ; } 00246 // ============================================================================ 00247 // average Kernel Time 00248 // ============================================================================ 00249 inline double 00250 ChronoEntity::kMeanTime () const { return m_kernel . flagMean () ; } 00251 // ============================================================================ 00252 // average User Time 00253 // ============================================================================ 00254 inline double 00255 ChronoEntity::uMeanTime () const { return m_user . flagMean () ; } 00256 // ============================================================================ 00257 // average Elapsed Time 00258 // ============================================================================ 00259 inline double 00260 ChronoEntity::eMeanTime () const { return m_elapsed . flagMean () ; } 00261 // ============================================================================ 00262 // r.m.s Kernel Time 00263 // ============================================================================ 00264 inline double 00265 ChronoEntity::kRMSTime () const { return m_kernel . flagRMS () ; } 00266 // ============================================================================ 00267 // r.m.s User Time 00268 // ============================================================================ 00269 inline double 00270 ChronoEntity::uRMSTime () const { return m_user . flagRMS () ; } 00271 // ============================================================================ 00272 // r.m.s Elapsed Time 00273 // ============================================================================ 00274 inline double 00275 ChronoEntity::eRMSTime () const { return m_elapsed . flagRMS () ; } 00276 // ============================================================================ 00277 // error in mean Kernel time 00278 // ============================================================================ 00279 inline double 00280 ChronoEntity::kMeanErrorTime () const { return m_kernel . flagMeanErr () ; } 00281 // ============================================================================ 00282 // error in mean User time 00283 // ============================================================================ 00284 inline double 00285 ChronoEntity::uMeanErrorTime () const { return m_user . flagMeanErr () ; } 00286 // ============================================================================ 00287 // error in mean Elapsed time 00288 // ============================================================================ 00289 inline double 00290 ChronoEntity::eMeanErrorTime () const { return m_elapsed . flagMeanErr () ; } 00291 // ============================================================================ 00292 // return the last delta-time of type "type" 00293 // ============================================================================ 00294 inline IChronoSvc::ChronoTime 00295 ChronoEntity::delta ( IChronoSvc::ChronoType type ) const 00296 { 00297 const IChronoSvc::ChronoTime result = -1 ; 00298 switch ( type ) 00299 { 00300 case IChronoSvc::USER : return m_delta.userTime<TimeUnit>(); 00301 case IChronoSvc::KERNEL : return m_delta.kernelTime<TimeUnit>(); 00302 case IChronoSvc::ELAPSED : return m_delta.elapsedTime<TimeUnit>(); 00303 default : return result; 00304 } 00305 // cannot reach this point 00306 } 00307 // ============================================================================ 00308 /* print the chrono according the format and units 00309 * @param fmt the format string 00310 * @param unit the unit 00311 * @return the string representations 00312 * @see boost::format 00313 */ 00314 // ============================================================================ 00315 inline std::string 00316 ChronoEntity::outputUserTime 00317 ( const std::string& fmt , 00318 System::TimeType unit ) const 00319 { 00320 return outputTime ( IChronoSvc::USER , fmt , unit ) ; 00321 } 00322 // ============================================================================ 00323 /* print the chrono according the format and units 00324 * @param fmt the format string 00325 * @param unit the unit 00326 * @return the string representations 00327 * @see boost::format 00328 */ 00329 // ============================================================================ 00330 inline std::string 00331 ChronoEntity::outputSystemTime 00332 ( const std::string& fmt , 00333 System::TimeType unit ) const 00334 { 00335 return outputTime ( IChronoSvc::KERNEL , fmt , unit ) ; 00336 } 00337 // ============================================================================ 00338 /* print the chrono according the format and units 00339 * @param fmt the format string 00340 * @param unit the unit 00341 * @return the string representations 00342 * @see boost::format 00343 */ 00344 // ============================================================================ 00345 inline std::string 00346 ChronoEntity::outputElapsedTime 00347 ( const std::string& fmt , 00348 System::TimeType unit ) const 00349 { 00350 return outputTime ( IChronoSvc::ELAPSED , fmt , unit ) ; 00351 } 00352 // ============================================================================ 00353 // The END 00354 // ============================================================================ 00355 #endif // GAUDIKERNEL_CHRONOENTITY_H 00356 // ============================================================================ 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366