ChronoEntity.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_CHRONOENTITY_H
2 #define GAUDIKERNEL_CHRONOENTITY_H 1
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 // GaudiKernel
7 // ============================================================================
8 #include "GaudiKernel/IChronoSvc.h"
9 #include "GaudiKernel/StatEntity.h"
10 #include "GaudiKernel/Timing.h"
11 // ============================================================================
22 {
23 public:
25  ChronoEntity() = default;
26 public:
27  // ==========================================================================
28  // The basic Chrono Operations
29  // ==========================================================================
33  IChronoSvc::ChronoStatus stop () ;
34  // ==========================================================================
36  inline IChronoSvc::ChronoTime delta ( IChronoSvc::ChronoType type ) const ;
38  inline IChronoSvc::ChronoStatus status() const ;
39  // ==========================================================================
40 public:
41  // ==========================================================
42  // Access to Chrono Statistics
43  // ==========================================================
45  inline unsigned long nOfMeasurements () const ;
46  // ==========================================================
48  inline double uMinimalTime () const ;
50  inline double kMinimalTime () const ;
52  inline double eMinimalTime () const ;
54  inline double uMaximalTime () const ;
56  inline double kMaximalTime () const ;
58  inline double eMaximalTime () const ;
60  inline double uTotalTime () const ;
62  inline double kTotalTime () const ;
64  inline double eTotalTime () const ;
66  inline double totalTime () const ;
68  inline double kMeanTime () const ;
70  inline double uMeanTime () const ;
72  inline double eMeanTime () const ;
74  inline double kRMSTime () const ;
76  inline double uRMSTime () const ;
78  inline double eRMSTime () const ;
80  inline double kMeanErrorTime () const ;
82  inline double uMeanErrorTime () const ;
84  inline double eMeanErrorTime () const ;
85  // ==========================================================================
86 public:
87  // ==========================================================================
89  bool operator<( const ChronoEntity& entity ) const;
90  // ==========================================================================
91 public:
92  // ==========================================================================
94  std::string outputUserTime () const ;
96  std::string outputSystemTime () const ;
98  std::string outputElapsedTime () const ;
99  // ==========================================================================
100 public:
101  // ==========================================================================
108  inline std::string outputUserTime
109  ( const std::string& fmt ,
110  System::TimeType unit ) const ;
117  inline std::string outputSystemTime
118  ( const std::string& fmt ,
119  System::TimeType unit ) const ;
126  inline std::string outputElapsedTime
127  ( const std::string& fmt ,
128  System::TimeType unit ) const ;
129  // ==========================================================================
148  std::string outputTime
149  ( IChronoSvc::ChronoType typ ,
150  const std::string& fmt ,
151  System::TimeType unit ) const ;
152  // ==========================================================================
153 protected:
154  // ==========================================================================
156  std::string format
157  ( const double total ,
158  const double minimal ,
159  const double mean ,
160  const double rms ,
161  const double maximal ,
162  const unsigned long number ) const ;
163  // ==========================================================================
164 private:
165  // ==========================================================================
173  StatEntity m_user ; // the actual storage of "user" time
175  StatEntity m_kernel ; // the actual storage of "kernel" time
177  StatEntity m_elapsed ; // the actual storage of "elapsed" time
179  static const System::TimeType TimeUnit = System::microSec;
180  // ==========================================================================
181 };
182 // ============================================================================
183 // return the status of chrono
184 // ============================================================================
186 ChronoEntity::status() const { return m_status; }
187 // ============================================================================
188 // number of chrono measurements
189 // ============================================================================
190 inline unsigned long
191 ChronoEntity::nOfMeasurements () const { return m_user . nEntries() ; }
192 // ============================================================================
193 // minimal measurement for user time
194 // ============================================================================
195 inline double ChronoEntity::uMinimalTime () const
196 { return m_user . flagMin () ; }
197 // ============================================================================
198 // minimal measurement for kernel time
199 // ============================================================================
200 inline double
201 ChronoEntity::kMinimalTime () const { return m_kernel . flagMin () ; }
202 // ============================================================================
203 // minimal measurement for elapsed time
204 // ============================================================================
205 inline double
206 ChronoEntity::eMinimalTime () const { return m_elapsed. flagMin () ; }
207 // ============================================================================
208 // maximal measurement for user time
209 // ============================================================================
210 inline double
211 ChronoEntity::uMaximalTime () const { return m_user . flagMax () ; }
212 // ============================================================================
213 // maximal measurement for kernel time
214 // ============================================================================
215 inline double
216 ChronoEntity::kMaximalTime () const { return m_kernel . flagMax () ; }
217 // ============================================================================
218 // maximal measurement for ellapsed time
219 // ============================================================================
220 inline double
221 ChronoEntity::eMaximalTime () const { return m_elapsed . flagMax () ; }
222 // ============================================================================
223 // total user time
224 // ============================================================================
225 inline double
226 ChronoEntity::uTotalTime () const { return m_user . flag () ; }
227 // ============================================================================
228 // total Kernel time
229 // ============================================================================
230 inline double
231 ChronoEntity::kTotalTime () const { return m_kernel . flag () ; }
232 // ============================================================================
233 // total Elapsed time
234 // ============================================================================
235 inline double
236 ChronoEntity::eTotalTime () const { return m_elapsed . flag () ; }
237 // ============================================================================
238 // total time
239 // ============================================================================
240 inline double
242 { return uTotalTime() + kTotalTime() ; }
243 // ============================================================================
244 // average Kernel Time
245 // ============================================================================
246 inline double
247 ChronoEntity::kMeanTime () const { return m_kernel . flagMean () ; }
248 // ============================================================================
249 // average User Time
250 // ============================================================================
251 inline double
252 ChronoEntity::uMeanTime () const { return m_user . flagMean () ; }
253 // ============================================================================
254 // average Elapsed Time
255 // ============================================================================
256 inline double
257 ChronoEntity::eMeanTime () const { return m_elapsed . flagMean () ; }
258 // ============================================================================
259 // r.m.s Kernel Time
260 // ============================================================================
261 inline double
262 ChronoEntity::kRMSTime () const { return m_kernel . flagRMS () ; }
263 // ============================================================================
264 // r.m.s User Time
265 // ============================================================================
266 inline double
267 ChronoEntity::uRMSTime () const { return m_user . flagRMS () ; }
268 // ============================================================================
269 // r.m.s Elapsed Time
270 // ============================================================================
271 inline double
272 ChronoEntity::eRMSTime () const { return m_elapsed . flagRMS () ; }
273 // ============================================================================
274 // error in mean Kernel time
275 // ============================================================================
276 inline double
277 ChronoEntity::kMeanErrorTime () const { return m_kernel . flagMeanErr () ; }
278 // ============================================================================
279 // error in mean User time
280 // ============================================================================
281 inline double
282 ChronoEntity::uMeanErrorTime () const { return m_user . flagMeanErr () ; }
283 // ============================================================================
284 // error in mean Elapsed time
285 // ============================================================================
286 inline double
287 ChronoEntity::eMeanErrorTime () const { return m_elapsed . flagMeanErr () ; }
288 // ============================================================================
289 // return the last delta-time of type "type"
290 // ============================================================================
293 {
294  const IChronoSvc::ChronoTime result = -1 ;
295  switch ( type )
296  {
297  case IChronoSvc::USER : return m_delta.userTime<TimeUnit>();
300  default : return result;
301  }
302  // cannot reach this point
303 }
304 // ============================================================================
305 /* print the chrono according the format and units
306  * @param fmt the format string
307  * @param unit the unit
308  * @return the string representations
309  * @see boost::format
310  */
311 // ============================================================================
312 inline std::string
314 ( const std::string& fmt ,
315  System::TimeType unit ) const
316 {
317  return outputTime ( IChronoSvc::USER , fmt , unit ) ;
318 }
319 // ============================================================================
320 /* print the chrono according the format and units
321  * @param fmt the format string
322  * @param unit the unit
323  * @return the string representations
324  * @see boost::format
325  */
326 // ============================================================================
327 inline std::string
329 ( const std::string& fmt ,
330  System::TimeType unit ) const
331 {
332  return outputTime ( IChronoSvc::KERNEL , fmt , unit ) ;
333 }
334 // ============================================================================
335 /* print the chrono according the format and units
336  * @param fmt the format string
337  * @param unit the unit
338  * @return the string representations
339  * @see boost::format
340  */
341 // ============================================================================
342 inline std::string
344 ( const std::string& fmt ,
345  System::TimeType unit ) const
346 {
347  return outputTime ( IChronoSvc::ELAPSED , fmt , unit ) ;
348 }
349 // ============================================================================
350 // The END
351 // ============================================================================
352 #endif // GAUDIKERNEL_CHRONOENTITY_H
353 // ============================================================================
std::string outputElapsedTime() const
print the chrono ;
double kMaximalTime() const
maximal measurement for kernel time
Definition: ChronoEntity.h:216
double uMinimalTime() const
minimal measurement for user time
Definition: ChronoEntity.h:195
IChronoSvc::ChronoStatus m_status
current status of this chrono object;
Definition: ChronoEntity.h:167
double uTotalTime() const
total user time
Definition: ChronoEntity.h:226
StatEntity m_elapsed
the actual storage of "elapsed" time
Definition: ChronoEntity.h:177
double kMeanErrorTime() const
error in mean Kernel time
Definition: ChronoEntity.h:277
#define GAUDI_API
Definition: Kernel.h:107
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
TimeValueType kernelTime() const
Retrieve the kernel time in the requested unit.
Definition: Timing.h:146
double kTotalTime() const
total Kernel time
Definition: ChronoEntity.h:231
TimeValueType userTime() const
Retrieve the user time in the requested unit.
Definition: Timing.h:150
StatEntity m_user
the actual storage of "user" time
Definition: ChronoEntity.h:173
double uRMSTime() const
r.m.s User Time
Definition: ChronoEntity.h:267
double kMinimalTime() const
minimal measurement for kernel time
Definition: ChronoEntity.h:201
double eMinimalTime() const
minimal measurement for elapsed time
Definition: ChronoEntity.h:206
double kRMSTime() const
r.m.s Kernel Time
Definition: ChronoEntity.h:262
std::string outputSystemTime() const
print the chrono ;
System::ProcessTime m_start
start stamp for current measurement of process times
Definition: ChronoEntity.h:171
System::ProcessTime m_delta
delta process times
Definition: ChronoEntity.h:169
double kMeanTime() const
average Kernel Time
Definition: ChronoEntity.h:247
double eMeanTime() const
average Elapsed Time
Definition: ChronoEntity.h:257
TimeType
Time type for conversion.
Definition: Timing.h:51
IChronoSvc::ChronoStatus status() const
return the status of chrono
Definition: ChronoEntity.h:186
StatEntity m_kernel
the actual storage of "kernel" time
Definition: ChronoEntity.h:175
Simple class to hold the time information of a process.
Definition: Timing.h:133
double eRMSTime() const
r.m.s Elapsed Time
Definition: ChronoEntity.h:272
double eMeanErrorTime() const
error in mean Elapsed time
Definition: ChronoEntity.h:287
double ChronoTime
Type of the delta-time.
Definition: IChronoSvc.h:41
double uMeanTime() const
average User Time
Definition: ChronoEntity.h:252
std::string outputUserTime() const
print the chrono ;
double totalTime() const
total time
Definition: ChronoEntity.h:241
TimeValueType elapsedTime() const
Retrieve the elapsed time in the requested unit.
Definition: Timing.h:154
double eMaximalTime() const
maximal measurement for elapsed time
Definition: ChronoEntity.h:221
unsigned long nOfMeasurements() const
number of chrono measurements
Definition: ChronoEntity.h:191
bool operator<(const Gaudi::Time &t1, const Gaudi::Time &t2)
Definition: Time.icpp:232
static const System::TimeType TimeUnit
internal unit used for the system time conversion (microseconds)
Definition: ChronoEntity.h:179
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:64
double uMaximalTime() const
maximal measurement for user time
Definition: ChronoEntity.h:211
double eTotalTime() const
total Elapsed time
Definition: ChronoEntity.h:236
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
tuple start
Definition: IOTest.py:88
string type
Definition: gaudirun.py:151
IChronoSvc::ChronoTime delta(IChronoSvc::ChronoType type) const
return the last delta-time of type "type"
Definition: ChronoEntity.h:292
double uMeanErrorTime() const
error in mean User time
Definition: ChronoEntity.h:282