Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 // ============================================================================
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  // ==========================================================================
92  ChronoEntity& operator+=( const ChronoEntity& entity );
93  // ==========================================================================
94 public:
95  // ==========================================================================
97  std::string outputUserTime () const ;
99  std::string outputSystemTime () const ;
101  std::string outputElapsedTime () const ;
102  // ==========================================================================
103 public:
104  // ==========================================================================
111  inline std::string outputUserTime
112  ( const std::string& fmt ,
113  System::TimeType unit ) const ;
120  inline std::string outputSystemTime
121  ( const std::string& fmt ,
122  System::TimeType unit ) const ;
129  inline std::string outputElapsedTime
130  ( const std::string& fmt ,
131  System::TimeType unit ) const ;
132  // ==========================================================================
151  std::string outputTime
152  ( IChronoSvc::ChronoType typ ,
153  const std::string& fmt ,
154  System::TimeType unit ) const ;
155  // ==========================================================================
156 protected:
157  // ==========================================================================
160  ( const double total ,
161  const double minimal ,
162  const double mean ,
163  const double rms ,
164  const double maximal ,
165  const unsigned long number ) const ;
166  // ==========================================================================
167 private:
168  // ==========================================================================
176  StatEntity m_user ; // the actual storage of "user" time
178  StatEntity m_kernel ; // the actual storage of "kernel" time
180  StatEntity m_elapsed ; // the actual storage of "elapsed" time
182  static const System::TimeType TimeUnit = System::microSec;
183  // ==========================================================================
184 };
185 // ============================================================================
186 // return the status of chrono
187 // ============================================================================
189 ChronoEntity::status() const { return m_status; }
190 // ============================================================================
191 // number of chrono measurements
192 // ============================================================================
193 inline unsigned long
194 ChronoEntity::nOfMeasurements () const { return m_user . nEntries() ; }
195 // ============================================================================
196 // minimal measurement for user time
197 // ============================================================================
198 inline double ChronoEntity::uMinimalTime () const
199 { return m_user . flagMin () ; }
200 // ============================================================================
201 // minimal measurement for kernel time
202 // ============================================================================
203 inline double
204 ChronoEntity::kMinimalTime () const { return m_kernel . flagMin () ; }
205 // ============================================================================
206 // minimal measurement for elapsed time
207 // ============================================================================
208 inline double
209 ChronoEntity::eMinimalTime () const { return m_elapsed. flagMin () ; }
210 // ============================================================================
211 // maximal measurement for user time
212 // ============================================================================
213 inline double
214 ChronoEntity::uMaximalTime () const { return m_user . flagMax () ; }
215 // ============================================================================
216 // maximal measurement for kernel time
217 // ============================================================================
218 inline double
219 ChronoEntity::kMaximalTime () const { return m_kernel . flagMax () ; }
220 // ============================================================================
221 // maximal measurement for ellapsed time
222 // ============================================================================
223 inline double
224 ChronoEntity::eMaximalTime () const { return m_elapsed . flagMax () ; }
225 // ============================================================================
226 // total user time
227 // ============================================================================
228 inline double
229 ChronoEntity::uTotalTime () const { return m_user . flag () ; }
230 // ============================================================================
231 // total Kernel time
232 // ============================================================================
233 inline double
234 ChronoEntity::kTotalTime () const { return m_kernel . flag () ; }
235 // ============================================================================
236 // total Elapsed time
237 // ============================================================================
238 inline double
239 ChronoEntity::eTotalTime () const { return m_elapsed . flag () ; }
240 // ============================================================================
241 // total time
242 // ============================================================================
243 inline double
245 { return uTotalTime() + kTotalTime() ; }
246 // ============================================================================
247 // average Kernel Time
248 // ============================================================================
249 inline double
250 ChronoEntity::kMeanTime () const { return m_kernel . flagMean () ; }
251 // ============================================================================
252 // average User Time
253 // ============================================================================
254 inline double
255 ChronoEntity::uMeanTime () const { return m_user . flagMean () ; }
256 // ============================================================================
257 // average Elapsed Time
258 // ============================================================================
259 inline double
260 ChronoEntity::eMeanTime () const { return m_elapsed . flagMean () ; }
261 // ============================================================================
262 // r.m.s Kernel Time
263 // ============================================================================
264 inline double
265 ChronoEntity::kRMSTime () const { return m_kernel . flagRMS () ; }
266 // ============================================================================
267 // r.m.s User Time
268 // ============================================================================
269 inline double
270 ChronoEntity::uRMSTime () const { return m_user . flagRMS () ; }
271 // ============================================================================
272 // r.m.s Elapsed Time
273 // ============================================================================
274 inline double
275 ChronoEntity::eRMSTime () const { return m_elapsed . flagRMS () ; }
276 // ============================================================================
277 // error in mean Kernel time
278 // ============================================================================
279 inline double
280 ChronoEntity::kMeanErrorTime () const { return m_kernel . flagMeanErr () ; }
281 // ============================================================================
282 // error in mean User time
283 // ============================================================================
284 inline double
285 ChronoEntity::uMeanErrorTime () const { return m_user . flagMeanErr () ; }
286 // ============================================================================
287 // error in mean Elapsed time
288 // ============================================================================
289 inline double
290 ChronoEntity::eMeanErrorTime () const { return m_elapsed . flagMeanErr () ; }
291 // ============================================================================
292 // return the last delta-time of type "type"
293 // ============================================================================
296 {
297  const IChronoSvc::ChronoTime result = -1 ;
298  switch ( type )
299  {
300  case IChronoSvc::USER : return m_delta.userTime<TimeUnit>();
301  case IChronoSvc::KERNEL : return m_delta.kernelTime<TimeUnit>();
302  case IChronoSvc::ELAPSED : return m_delta.elapsedTime<TimeUnit>();
303  default : return result;
304  }
305  // cannot reach this point
306 }
307 // ============================================================================
308 /* print the chrono according the format and units
309  * @param fmt the format string
310  * @param unit the unit
311  * @return the string representations
312  * @see boost::format
313  */
314 // ============================================================================
315 inline std::string
317 ( const std::string& fmt ,
318  System::TimeType unit ) const
319 {
320  return outputTime ( IChronoSvc::USER , fmt , unit ) ;
321 }
322 // ============================================================================
323 /* print the chrono according the format and units
324  * @param fmt the format string
325  * @param unit the unit
326  * @return the string representations
327  * @see boost::format
328  */
329 // ============================================================================
330 inline std::string
332 ( const std::string& fmt ,
333  System::TimeType unit ) const
334 {
335  return outputTime ( IChronoSvc::KERNEL , fmt , unit ) ;
336 }
337 // ============================================================================
338 /* print the chrono according the format and units
339  * @param fmt the format string
340  * @param unit the unit
341  * @return the string representations
342  * @see boost::format
343  */
344 // ============================================================================
345 inline std::string
347 ( const std::string& fmt ,
348  System::TimeType unit ) const
349 {
350  return outputTime ( IChronoSvc::ELAPSED , fmt , unit ) ;
351 }
352 // ============================================================================
353 // The END
354 // ============================================================================
355 #endif // GAUDIKERNEL_CHRONOENTITY_H
356 // ============================================================================
std::string outputElapsedTime() const
print the chrono ;
double kMaximalTime() const
maximal measurement for kernel time
Definition: ChronoEntity.h:219
double uMinimalTime() const
minimal measurement for user time
Definition: ChronoEntity.h:198
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
double uTotalTime() const
total user time
Definition: ChronoEntity.h:229
StatEntity m_elapsed
the actual storage of "elapsed" time
Definition: ChronoEntity.h:180
double kMeanErrorTime() const
error in mean Kernel time
Definition: ChronoEntity.h:280
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
double kTotalTime() const
total Kernel time
Definition: ChronoEntity.h:234
StatEntity m_user
the actual storage of "user" time
Definition: ChronoEntity.h:176
double uRMSTime() const
r.m.s User Time
Definition: ChronoEntity.h:270
double kMinimalTime() const
minimal measurement for kernel time
Definition: ChronoEntity.h:204
double eMinimalTime() const
minimal measurement for elapsed time
Definition: ChronoEntity.h:209
double kRMSTime() const
r.m.s Kernel Time
Definition: ChronoEntity.h:265
std::string outputSystemTime() const
print the chrono ;
STL class.
System::ProcessTime m_start
start stamp for current measurement of process times
Definition: ChronoEntity.h:174
System::ProcessTime m_delta
delta process times
Definition: ChronoEntity.h:172
double kMeanTime() const
average Kernel Time
Definition: ChronoEntity.h:250
double eMeanTime() const
average Elapsed Time
Definition: ChronoEntity.h:260
TimeType
Time type for conversion.
Definition: Timing.h:57
IChronoSvc::ChronoStatus status() const
return the status of chrono
Definition: ChronoEntity.h:189
StatEntity m_kernel
the actual storage of "kernel" time
Definition: ChronoEntity.h:178
start
Definition: IOTest.py:88
Simple class to hold the time information of a process.
Definition: Timing.h:146
double eRMSTime() const
r.m.s Elapsed Time
Definition: ChronoEntity.h:275
double eMeanErrorTime() const
error in mean Elapsed time
Definition: ChronoEntity.h:290
double ChronoTime
Type of the delta-time.
Definition: IChronoSvc.h:41
double uMeanTime() const
average User Time
Definition: ChronoEntity.h:255
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:185
std::string outputUserTime() const
print the chrono ;
double totalTime() const
total time
Definition: ChronoEntity.h:244
double eMaximalTime() const
maximal measurement for elapsed time
Definition: ChronoEntity.h:224
unsigned long nOfMeasurements() const
number of chrono measurements
Definition: ChronoEntity.h:194
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
double uMaximalTime() const
maximal measurement for user time
Definition: ChronoEntity.h:214
#define GAUDI_API
Definition: Kernel.h:107
double eTotalTime() const
total Elapsed time
Definition: ChronoEntity.h:239
IChronoSvc::ChronoTime delta(IChronoSvc::ChronoType type) const
return the last delta-time of type "type"
Definition: ChronoEntity.h:295
double uMeanErrorTime() const
error in mean User time
Definition: ChronoEntity.h:285