The Gaudi Framework  v29r0 (ff2e7097)
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 
27 public:
28  // ==========================================================================
29  // The basic Chrono Operations
30  // ==========================================================================
35  // ==========================================================================
39  inline IChronoSvc::ChronoStatus status() const;
40  // ==========================================================================
41 public:
42  // ==========================================================
43  // Access to Chrono Statistics
44  // ==========================================================
46  inline unsigned long nOfMeasurements() const;
47  // ==========================================================
49  inline double uMinimalTime() const;
51  inline double kMinimalTime() const;
53  inline double eMinimalTime() const;
55  inline double uMaximalTime() const;
57  inline double kMaximalTime() const;
59  inline double eMaximalTime() const;
61  inline double uTotalTime() const;
63  inline double kTotalTime() const;
65  inline double eTotalTime() const;
67  inline double totalTime() const;
69  inline double kMeanTime() const;
71  inline double uMeanTime() const;
73  inline double eMeanTime() const;
75  inline double kRMSTime() const;
77  inline double uRMSTime() const;
79  inline double eRMSTime() const;
81  inline double kMeanErrorTime() const;
83  inline double uMeanErrorTime() const;
85  inline double eMeanErrorTime() const;
86  // ==========================================================================
87 public:
88  // ==========================================================================
90  bool operator<( const ChronoEntity& entity ) const;
91  // ==========================================================================
93  ChronoEntity& operator+=( const ChronoEntity& entity );
94  // ==========================================================================
95 public:
96  // ==========================================================================
98  std::string outputUserTime() const;
100  std::string outputSystemTime() const;
102  std::string outputElapsedTime() const;
103  // ==========================================================================
104 public:
105  // ==========================================================================
112  inline std::string outputUserTime( const std::string& fmt, System::TimeType unit ) const;
119  inline std::string outputSystemTime( const std::string& fmt, System::TimeType unit ) const;
126  inline std::string outputElapsedTime( const std::string& fmt, System::TimeType unit ) const;
127  // ==========================================================================
146  std::string outputTime( IChronoSvc::ChronoType typ, const std::string& fmt, System::TimeType unit ) const;
147  // ==========================================================================
148 protected:
149  // ==========================================================================
151  std::string format( const double total, const double minimal, const double mean, const double rms,
152  const double maximal, const unsigned long number ) const;
153  // ==========================================================================
154 private:
155  // ==========================================================================
163  StatEntity m_user; // the actual storage of "user" time
165  StatEntity m_kernel; // the actual storage of "kernel" time
167  StatEntity m_elapsed; // the actual storage of "elapsed" time
169  static const System::TimeType TimeUnit = System::microSec;
170  // ==========================================================================
171 };
172 // ============================================================================
173 // return the status of chrono
174 // ============================================================================
175 inline IChronoSvc::ChronoStatus ChronoEntity::status() const { return m_status; }
176 // ============================================================================
177 // number of chrono measurements
178 // ============================================================================
179 inline unsigned long ChronoEntity::nOfMeasurements() const { return m_user.nEntries(); }
180 // ============================================================================
181 // minimal measurement for user time
182 // ============================================================================
183 inline double ChronoEntity::uMinimalTime() const { return m_user.flagMin(); }
184 // ============================================================================
185 // minimal measurement for kernel time
186 // ============================================================================
187 inline double ChronoEntity::kMinimalTime() const { return m_kernel.flagMin(); }
188 // ============================================================================
189 // minimal measurement for elapsed time
190 // ============================================================================
191 inline double ChronoEntity::eMinimalTime() const { return m_elapsed.flagMin(); }
192 // ============================================================================
193 // maximal measurement for user time
194 // ============================================================================
195 inline double ChronoEntity::uMaximalTime() const { return m_user.flagMax(); }
196 // ============================================================================
197 // maximal measurement for kernel time
198 // ============================================================================
199 inline double ChronoEntity::kMaximalTime() const { return m_kernel.flagMax(); }
200 // ============================================================================
201 // maximal measurement for ellapsed time
202 // ============================================================================
203 inline double ChronoEntity::eMaximalTime() const { return m_elapsed.flagMax(); }
204 // ============================================================================
205 // total user time
206 // ============================================================================
207 inline double ChronoEntity::uTotalTime() const { return m_user.flag(); }
208 // ============================================================================
209 // total Kernel time
210 // ============================================================================
211 inline double ChronoEntity::kTotalTime() const { return m_kernel.flag(); }
212 // ============================================================================
213 // total Elapsed time
214 // ============================================================================
215 inline double ChronoEntity::eTotalTime() const { return m_elapsed.flag(); }
216 // ============================================================================
217 // total time
218 // ============================================================================
219 inline double ChronoEntity::totalTime() const { return uTotalTime() + kTotalTime(); }
220 // ============================================================================
221 // average Kernel Time
222 // ============================================================================
223 inline double ChronoEntity::kMeanTime() const { return m_kernel.flagMean(); }
224 // ============================================================================
225 // average User Time
226 // ============================================================================
227 inline double ChronoEntity::uMeanTime() const { return m_user.flagMean(); }
228 // ============================================================================
229 // average Elapsed Time
230 // ============================================================================
231 inline double ChronoEntity::eMeanTime() const { return m_elapsed.flagMean(); }
232 // ============================================================================
233 // r.m.s Kernel Time
234 // ============================================================================
235 inline double ChronoEntity::kRMSTime() const { return m_kernel.flagRMS(); }
236 // ============================================================================
237 // r.m.s User Time
238 // ============================================================================
239 inline double ChronoEntity::uRMSTime() const { return m_user.flagRMS(); }
240 // ============================================================================
241 // r.m.s Elapsed Time
242 // ============================================================================
243 inline double ChronoEntity::eRMSTime() const { return m_elapsed.flagRMS(); }
244 // ============================================================================
245 // error in mean Kernel time
246 // ============================================================================
247 inline double ChronoEntity::kMeanErrorTime() const { return m_kernel.flagMeanErr(); }
248 // ============================================================================
249 // error in mean User time
250 // ============================================================================
251 inline double ChronoEntity::uMeanErrorTime() const { return m_user.flagMeanErr(); }
252 // ============================================================================
253 // error in mean Elapsed time
254 // ============================================================================
255 inline double ChronoEntity::eMeanErrorTime() const { return m_elapsed.flagMeanErr(); }
256 // ============================================================================
257 // return the last delta-time of type "type"
258 // ============================================================================
260 {
261  const IChronoSvc::ChronoTime result = -1;
262  switch ( type ) {
263  case IChronoSvc::USER:
264  return m_delta.userTime<TimeUnit>();
265  case IChronoSvc::KERNEL:
266  return m_delta.kernelTime<TimeUnit>();
267  case IChronoSvc::ELAPSED:
268  return m_delta.elapsedTime<TimeUnit>();
269  default:
270  return result;
271  }
272  // cannot reach this point
273 }
274 // ============================================================================
275 /* print the chrono according the format and units
276  * @param fmt the format string
277  * @param unit the unit
278  * @return the string representations
279  * @see boost::format
280  */
281 // ============================================================================
283 {
284  return outputTime( IChronoSvc::USER, fmt, unit );
285 }
286 // ============================================================================
287 /* print the chrono according the format and units
288  * @param fmt the format string
289  * @param unit the unit
290  * @return the string representations
291  * @see boost::format
292  */
293 // ============================================================================
295 {
296  return outputTime( IChronoSvc::KERNEL, fmt, unit );
297 }
298 // ============================================================================
299 /* print the chrono according the format and units
300  * @param fmt the format string
301  * @param unit the unit
302  * @return the string representations
303  * @see boost::format
304  */
305 // ============================================================================
307 {
308  return outputTime( IChronoSvc::ELAPSED, fmt, unit );
309 }
310 // ============================================================================
311 // The END
312 // ============================================================================
313 #endif // GAUDIKERNEL_CHRONOENTITY_H
314 // ============================================================================
std::string outputElapsedTime() const
print the chrono ;
double kMaximalTime() const
maximal measurement for kernel time
Definition: ChronoEntity.h:199
double uMinimalTime() const
minimal measurement for user time
Definition: ChronoEntity.h:183
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
double uTotalTime() const
total user time
Definition: ChronoEntity.h:207
StatEntity m_elapsed
the actual storage of "elapsed" time
Definition: ChronoEntity.h:167
double kMeanErrorTime() const
error in mean Kernel time
Definition: ChronoEntity.h:247
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:211
StatEntity m_user
the actual storage of "user" time
Definition: ChronoEntity.h:163
double uRMSTime() const
r.m.s User Time
Definition: ChronoEntity.h:239
double kMinimalTime() const
minimal measurement for kernel time
Definition: ChronoEntity.h:187
double eMinimalTime() const
minimal measurement for elapsed time
Definition: ChronoEntity.h:191
double kRMSTime() const
r.m.s Kernel Time
Definition: ChronoEntity.h:235
std::string outputSystemTime() const
print the chrono ;
STL class.
System::ProcessTime m_start
start stamp for current measurement of process times
Definition: ChronoEntity.h:161
System::ProcessTime m_delta
delta process times
Definition: ChronoEntity.h:159
double kMeanTime() const
average Kernel Time
Definition: ChronoEntity.h:223
double eMeanTime() const
average Elapsed Time
Definition: ChronoEntity.h:231
TimeType
Time type for conversion.
Definition: Timing.h:58
IChronoSvc::ChronoStatus status() const
return the status of chrono
Definition: ChronoEntity.h:175
StatEntity m_kernel
the actual storage of "kernel" time
Definition: ChronoEntity.h:165
start
Definition: IOTest.py:99
Simple class to hold the time information of a process.
Definition: Timing.h:147
double eRMSTime() const
r.m.s Elapsed Time
Definition: ChronoEntity.h:243
double eMeanErrorTime() const
error in mean Elapsed time
Definition: ChronoEntity.h:255
double ChronoTime
Type of the delta-time.
Definition: IChronoSvc.h:41
double uMeanTime() const
average User Time
Definition: ChronoEntity.h:227
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:206
std::string outputUserTime() const
print the chrono ;
double totalTime() const
total time
Definition: ChronoEntity.h:219
double eMaximalTime() const
maximal measurement for elapsed time
Definition: ChronoEntity.h:203
unsigned long nOfMeasurements() const
number of chrono measurements
Definition: ChronoEntity.h:179
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
double uMaximalTime() const
maximal measurement for user time
Definition: ChronoEntity.h:195
#define GAUDI_API
Definition: Kernel.h:110
double eTotalTime() const
total Elapsed time
Definition: ChronoEntity.h:215
IChronoSvc::ChronoTime delta(IChronoSvc::ChronoType type) const
return the last delta-time of type "type"
Definition: ChronoEntity.h:259
double uMeanErrorTime() const
error in mean User time
Definition: ChronoEntity.h:251