Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 public:
24  ChronoEntity() = default;
25 
26 public:
27  // ==========================================================================
28  // The basic Chrono Operations
29  // ==========================================================================
34  // ==========================================================================
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  friend bool operator<( ChronoEntity const& lhs, ChronoEntity const& rhs ) {
90  return std::make_tuple( lhs.totalTime(), lhs.m_user, lhs.m_kernel, lhs.m_elapsed ) <
91  std::make_tuple( rhs.totalTime(), rhs.m_user, rhs.m_kernel, rhs.m_elapsed );
92  }
93  // ==========================================================================
95  ChronoEntity& operator+=( const ChronoEntity& entity );
96  // ==========================================================================
97 public:
98  // ==========================================================================
100  std::string outputUserTime() const;
102  std::string outputSystemTime() const;
104  std::string outputElapsedTime() const;
105  // ==========================================================================
106 public:
107  // ==========================================================================
114  inline std::string outputUserTime( const std::string& fmt, System::TimeType unit ) const;
121  inline std::string outputSystemTime( const std::string& fmt, System::TimeType unit ) const;
128  inline std::string outputElapsedTime( const std::string& fmt, System::TimeType unit ) const;
129  // ==========================================================================
148  std::string outputTime( IChronoSvc::ChronoType typ, const std::string& fmt, System::TimeType unit ) const;
149  // ==========================================================================
150 protected:
151  // ==========================================================================
153  std::string format( const double total, const double minimal, const double mean, const double rms,
154  const double maximal, const unsigned long number ) const;
155  // ==========================================================================
156 private:
157  // ==========================================================================
165  StatEntity m_user; // the actual storage of "user" time
167  StatEntity m_kernel; // the actual storage of "kernel" time
169  StatEntity m_elapsed; // the actual storage of "elapsed" time
171  static const System::TimeType TimeUnit = System::microSec;
172  // ==========================================================================
173 };
174 // ============================================================================
175 // return the status of chrono
176 // ============================================================================
177 inline IChronoSvc::ChronoStatus ChronoEntity::status() const { return m_status; }
178 // ============================================================================
179 // number of chrono measurements
180 // ============================================================================
181 inline unsigned long ChronoEntity::nOfMeasurements() const { return m_user.nEntries(); }
182 // ============================================================================
183 // minimal measurement for user time
184 // ============================================================================
185 inline double ChronoEntity::uMinimalTime() const { return m_user.flagMin(); }
186 // ============================================================================
187 // minimal measurement for kernel time
188 // ============================================================================
189 inline double ChronoEntity::kMinimalTime() const { return m_kernel.flagMin(); }
190 // ============================================================================
191 // minimal measurement for elapsed time
192 // ============================================================================
193 inline double ChronoEntity::eMinimalTime() const { return m_elapsed.flagMin(); }
194 // ============================================================================
195 // maximal measurement for user time
196 // ============================================================================
197 inline double ChronoEntity::uMaximalTime() const { return m_user.flagMax(); }
198 // ============================================================================
199 // maximal measurement for kernel time
200 // ============================================================================
201 inline double ChronoEntity::kMaximalTime() const { return m_kernel.flagMax(); }
202 // ============================================================================
203 // maximal measurement for ellapsed time
204 // ============================================================================
205 inline double ChronoEntity::eMaximalTime() const { return m_elapsed.flagMax(); }
206 // ============================================================================
207 // total user time
208 // ============================================================================
209 inline double ChronoEntity::uTotalTime() const { return m_user.flag(); }
210 // ============================================================================
211 // total Kernel time
212 // ============================================================================
213 inline double ChronoEntity::kTotalTime() const { return m_kernel.flag(); }
214 // ============================================================================
215 // total Elapsed time
216 // ============================================================================
217 inline double ChronoEntity::eTotalTime() const { return m_elapsed.flag(); }
218 // ============================================================================
219 // total time
220 // ============================================================================
221 inline double ChronoEntity::totalTime() const { return uTotalTime() + kTotalTime(); }
222 // ============================================================================
223 // average Kernel Time
224 // ============================================================================
225 inline double ChronoEntity::kMeanTime() const { return m_kernel.flagMean(); }
226 // ============================================================================
227 // average User Time
228 // ============================================================================
229 inline double ChronoEntity::uMeanTime() const { return m_user.flagMean(); }
230 // ============================================================================
231 // average Elapsed Time
232 // ============================================================================
233 inline double ChronoEntity::eMeanTime() const { return m_elapsed.flagMean(); }
234 // ============================================================================
235 // r.m.s Kernel Time
236 // ============================================================================
237 inline double ChronoEntity::kRMSTime() const { return m_kernel.flagRMS(); }
238 // ============================================================================
239 // r.m.s User Time
240 // ============================================================================
241 inline double ChronoEntity::uRMSTime() const { return m_user.flagRMS(); }
242 // ============================================================================
243 // r.m.s Elapsed Time
244 // ============================================================================
245 inline double ChronoEntity::eRMSTime() const { return m_elapsed.flagRMS(); }
246 // ============================================================================
247 // error in mean Kernel time
248 // ============================================================================
249 inline double ChronoEntity::kMeanErrorTime() const { return m_kernel.flagMeanErr(); }
250 // ============================================================================
251 // error in mean User time
252 // ============================================================================
253 inline double ChronoEntity::uMeanErrorTime() const { return m_user.flagMeanErr(); }
254 // ============================================================================
255 // error in mean Elapsed time
256 // ============================================================================
257 inline double ChronoEntity::eMeanErrorTime() const { return m_elapsed.flagMeanErr(); }
258 // ============================================================================
259 // return the last delta-time of type "type"
260 // ============================================================================
262  const IChronoSvc::ChronoTime result = -1;
263  switch ( type ) {
264  case IChronoSvc::USER:
265  return m_delta.userTime<TimeUnit>();
266  case IChronoSvc::KERNEL:
267  return m_delta.kernelTime<TimeUnit>();
268  case IChronoSvc::ELAPSED:
269  return m_delta.elapsedTime<TimeUnit>();
270  default:
271  return result;
272  }
273  // cannot reach this point
274 }
275 // ============================================================================
276 /* print the chrono according the format and units
277  * @param fmt the format string
278  * @param unit the unit
279  * @return the string representations
280  * @see boost::format
281  */
282 // ============================================================================
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  return outputTime( IChronoSvc::KERNEL, fmt, unit );
296 }
297 // ============================================================================
298 /* print the chrono according the format and units
299  * @param fmt the format string
300  * @param unit the unit
301  * @return the string representations
302  * @see boost::format
303  */
304 // ============================================================================
306  return outputTime( IChronoSvc::ELAPSED, fmt, unit );
307 }
308 // ============================================================================
309 // The END
310 // ============================================================================
311 #endif // GAUDIKERNEL_CHRONOENTITY_H
std::string outputElapsedTime() const
print the chrono ;
double kMaximalTime() const
maximal measurement for kernel time
Definition: ChronoEntity.h:201
double uMinimalTime() const
minimal measurement for user time
Definition: ChronoEntity.h:185
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
double uTotalTime() const
total user time
Definition: ChronoEntity.h:209
StatEntity m_elapsed
the actual storage of "elapsed" time
Definition: ChronoEntity.h:169
double kMeanErrorTime() const
error in mean Kernel time
Definition: ChronoEntity.h:249
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:213
StatEntity m_user
the actual storage of "user" time
Definition: ChronoEntity.h:165
double uRMSTime() const
r.m.s User Time
Definition: ChronoEntity.h:241
T make_tuple(T...args)
double kMinimalTime() const
minimal measurement for kernel time
Definition: ChronoEntity.h:189
double eMinimalTime() const
minimal measurement for elapsed time
Definition: ChronoEntity.h:193
double kRMSTime() const
r.m.s Kernel Time
Definition: ChronoEntity.h:237
std::string outputSystemTime() const
print the chrono ;
STL class.
System::ProcessTime m_start
start stamp for current measurement of process times
Definition: ChronoEntity.h:163
System::ProcessTime m_delta
delta process times
Definition: ChronoEntity.h:161
double kMeanTime() const
average Kernel Time
Definition: ChronoEntity.h:225
double eMeanTime() const
average Elapsed Time
Definition: ChronoEntity.h:233
TimeType
Time type for conversion.
Definition: Timing.h:57
IChronoSvc::ChronoStatus status() const
return the status of chrono
Definition: ChronoEntity.h:177
StatEntity m_kernel
the actual storage of "kernel" time
Definition: ChronoEntity.h:167
start
Definition: IOTest.py:97
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:245
double eMeanErrorTime() const
error in mean Elapsed time
Definition: ChronoEntity.h:257
double ChronoTime
Type of the delta-time.
Definition: IChronoSvc.h:39
double uMeanTime() const
average User Time
Definition: ChronoEntity.h:229
std::string outputUserTime() const
print the chrono ;
double totalTime() const
total time
Definition: ChronoEntity.h:221
double eMaximalTime() const
maximal measurement for elapsed time
Definition: ChronoEntity.h:205
unsigned long nOfMeasurements() const
number of chrono measurements
Definition: ChronoEntity.h:181
friend bool operator<(ChronoEntity const &lhs, ChronoEntity const &rhs)
comparison operator
Definition: ChronoEntity.h:89
backward compatible StatEntity class.
Definition: Counters.h:837
double uMaximalTime() const
maximal measurement for user time
Definition: ChronoEntity.h:197
#define GAUDI_API
Definition: Kernel.h:71
double eTotalTime() const
total Elapsed time
Definition: ChronoEntity.h:217
IChronoSvc::ChronoTime delta(IChronoSvc::ChronoType type) const
return the last delta-time of type "type"
Definition: ChronoEntity.h:261
double uMeanErrorTime() const
error in mean User time
Definition: ChronoEntity.h:253