| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 // ============================================================================
21 class GAUDI_API ChronoEntity
22 {
23 public:
25 ChronoEntity() = default;
26 public:
27 // ==========================================================================
28 // The basic Chrono Operations
29 // ==========================================================================
31 IChronoSvc::ChronoStatus start() ;
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 // ==========================================================================
159 std::string format
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 // ==========================================================================
170 IChronoSvc::ChronoStatus m_status = IChronoSvc::UNKNOWN;
172 System::ProcessTime m_delta;
174 System::ProcessTime m_start;
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 // ============================================================================
188 inline IChronoSvc::ChronoStatus
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
244 ChronoEntity::totalTime () const
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 // ============================================================================
294 inline IChronoSvc::ChronoTime
295 ChronoEntity::delta ( IChronoSvc::ChronoType type ) const
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
316 ChronoEntity::outputUserTime
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
331 ChronoEntity::outputSystemTime
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
346 ChronoEntity::outputElapsedTime
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 // ============================================================================
ChronoEntity::outputElapsedTime
std::string outputElapsedTime() const
print the chrono ;
Definition: ChronoEntity.cpp:110
ChronoEntity::kMaximalTime
double kMaximalTime() const
maximal measurement for kernel time
Definition: ChronoEntity.h:219
ChronoEntity::uMinimalTime
double uMinimalTime() const
minimal measurement for user time
Definition: ChronoEntity.h:198
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
ChronoEntity::m_status
IChronoSvc::ChronoStatus m_status
current status of this chrono object;
Definition: ChronoEntity.h:170
ChronoEntity::uTotalTime
double uTotalTime() const
total user time
Definition: ChronoEntity.h:229
ChronoEntity::m_elapsed
StatEntity m_elapsed
the actual storage of "elapsed" time
Definition: ChronoEntity.h:180
ChronoEntity::kMeanErrorTime
double kMeanErrorTime() const
error in mean Kernel time
Definition: ChronoEntity.h:280
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
System::ProcessTime::kernelTime
TimeValueType kernelTime() const
Retrieve the kernel time in the requested unit.
Definition: Timing.h:146
ChronoEntity::kTotalTime
double kTotalTime() const
total Kernel time
Definition: ChronoEntity.h:234
IChronoSvc::ChronoStatus
ChronoStatus
Definition: IChronoSvc.h:46
System::ProcessTime::userTime
TimeValueType userTime() const
Retrieve the user time in the requested unit.
Definition: Timing.h:150
ChronoEntity::m_user
StatEntity m_user
the actual storage of "user" time
Definition: ChronoEntity.h:176
ChronoEntity::uRMSTime
double uRMSTime() const
r.m.s User Time
Definition: ChronoEntity.h:270
IChronoSvc::KERNEL
Definition: IChronoSvc.h:56
ChronoEntity::kMinimalTime
double kMinimalTime() const
minimal measurement for kernel time
Definition: ChronoEntity.h:204
ChronoEntity::eMinimalTime
double eMinimalTime() const
minimal measurement for elapsed time
Definition: ChronoEntity.h:209
ChronoEntity::kRMSTime
double kRMSTime() const
r.m.s Kernel Time
Definition: ChronoEntity.h:265
ChronoEntity::outputSystemTime
std::string outputSystemTime() const
print the chrono ;
Definition: ChronoEntity.cpp:98
std::string
STL class.
IChronoSvc::USER
Definition: IChronoSvc.h:55
ChronoEntity::m_start
System::ProcessTime m_start
start stamp for current measurement of process times
Definition: ChronoEntity.h:174
ChronoEntity::m_delta
System::ProcessTime m_delta
delta process times
Definition: ChronoEntity.h:172
ChronoEntity::kMeanTime
double kMeanTime() const
average Kernel Time
Definition: ChronoEntity.h:250
ChronoEntity::eMeanTime
double eMeanTime() const
average Elapsed Time
Definition: ChronoEntity.h:260
gaudirun.type
string type
Definition: gaudirun.py:151
System::microSec
Definition: Timing.h:51
System::TimeType
TimeType
Time type for conversion.
Definition: Timing.h:51
ChronoEntity::status
IChronoSvc::ChronoStatus status() const
return the status of chrono
Definition: ChronoEntity.h:189
ChronoEntity::m_kernel
StatEntity m_kernel
the actual storage of "kernel" time
Definition: ChronoEntity.h:178
System::ProcessTime
Simple class to hold the time information of a process.
Definition: Timing.h:133
ChronoEntity::eRMSTime
double eRMSTime() const
r.m.s Elapsed Time
Definition: ChronoEntity.h:275
ChronoEntity::eMeanErrorTime
double eMeanErrorTime() const
error in mean Elapsed time
Definition: ChronoEntity.h:290
IChronoSvc::ELAPSED
Definition: IChronoSvc.h:57
Timing.h
IChronoSvc::ChronoTime
double ChronoTime
Type of the delta-time.
Definition: IChronoSvc.h:41
ChronoEntity::uMeanTime
double uMeanTime() const
average User Time
Definition: ChronoEntity.h:255
operator<
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:119
ChronoEntity::outputUserTime
std::string outputUserTime() const
print the chrono ;
Definition: ChronoEntity.cpp:85
ChronoEntity::totalTime
double totalTime() const
total time
Definition: ChronoEntity.h:244
IChronoSvc::UNKNOWN
Definition: IChronoSvc.h:48
System::ProcessTime::elapsedTime
TimeValueType elapsedTime() const
Retrieve the elapsed time in the requested unit.
Definition: Timing.h:154
ChronoEntity::eMaximalTime
double eMaximalTime() const
maximal measurement for elapsed time
Definition: ChronoEntity.h:224
StatEntity.h
IChronoSvc::ChronoType
ChronoType
Definition: IChronoSvc.h:53
ChronoEntity::TimeUnit
static const System::TimeType TimeUnit
internal unit used for the system time conversion (microseconds)
Definition: ChronoEntity.h:182
ChronoEntity::nOfMeasurements
unsigned long nOfMeasurements() const
number of chrono measurements
Definition: ChronoEntity.h:194
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:64
ChronoEntity::uMaximalTime
double uMaximalTime() const
maximal measurement for user time
Definition: ChronoEntity.h:214
IChronoSvc.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
ChronoEntity::eTotalTime
double eTotalTime() const
total Elapsed time
Definition: ChronoEntity.h:239
IOTest.start
tuple start
Definition: IOTest.py:88
ChronoEntity::delta
IChronoSvc::ChronoTime delta(IChronoSvc::ChronoType type) const
return the last delta-time of type "type"
Definition: ChronoEntity.h:295
ChronoEntity::uMeanErrorTime
double uMeanErrorTime() const
error in mean User time
Definition: ChronoEntity.h:285