| The Gaudi Framework v32r1 (f65d50dc)

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 public:
24 ChronoEntity() = default;
25
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 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 // ==========================================================================
159 IChronoSvc::ChronoStatus m_status = IChronoSvc::UNKNOWN;
161 System::ProcessTime m_delta;
163 System::ProcessTime m_start;
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 // ============================================================================
261 inline IChronoSvc::ChronoTime ChronoEntity::delta( IChronoSvc::ChronoType type ) const {
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 // ============================================================================
283 inline std::string ChronoEntity::outputUserTime( const std::string& fmt, System::TimeType unit ) const {
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 // ============================================================================
294 inline std::string ChronoEntity::outputSystemTime( const std::string& fmt, System::TimeType unit ) const {
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 // ============================================================================
305 inline std::string ChronoEntity::outputElapsedTime( const std::string& fmt, System::TimeType unit ) const {
306 return outputTime( IChronoSvc::ELAPSED, fmt, unit );
307 }
308 // ============================================================================
309 // The END
310 // ============================================================================
311 #endif // GAUDIKERNEL_CHRONOENTITY_H
ChronoEntity::outputTime
std::string outputTime(IChronoSvc::ChronoType typ, const std::string &fmt, System::TimeType unit) const
print the chrono according the format and units
Definition: ChronoEntity.cpp:165
System::ProcessTime::userTime
TimeValueType userTime() const
Retrieve the user time in the requested unit.
Definition: Timing.h:164
ChronoEntity::eRMSTime
double eRMSTime() const
r.m.s Elapsed Time
Definition: ChronoEntity.h:245
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:109
ChronoEntity::uMeanErrorTime
double uMeanErrorTime() const
error in mean User time
Definition: ChronoEntity.h:253
ChronoEntity::m_status
IChronoSvc::ChronoStatus m_status
current status of this chrono object;
Definition: ChronoEntity.h:159
ChronoEntity::m_elapsed
StatEntity m_elapsed
the actual storage of "elapsed" time
Definition: ChronoEntity.h:169
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
ChronoEntity::delta
IChronoSvc::ChronoTime delta(IChronoSvc::ChronoType type) const
return the last delta-time of type "type"
Definition: ChronoEntity.h:261
ChronoEntity::kMeanErrorTime
double kMeanErrorTime() const
error in mean Kernel time
Definition: ChronoEntity.h:249
IChronoSvc::ChronoStatus
ChronoStatus
Definition: IChronoSvc.h:44
System::ProcessTime::elapsedTime
TimeValueType elapsedTime() const
Retrieve the elapsed time in the requested unit.
Definition: Timing.h:170
ChronoEntity::m_user
StatEntity m_user
the actual storage of "user" time
Definition: ChronoEntity.h:165
std::make_tuple
T make_tuple(T... args)
ChronoEntity::uMinimalTime
double uMinimalTime() const
minimal measurement for user time
Definition: ChronoEntity.h:185
IChronoSvc::KERNEL
Definition: IChronoSvc.h:46
ChronoEntity::eMeanErrorTime
double eMeanErrorTime() const
error in mean Elapsed time
Definition: ChronoEntity.h:257
IOTest.start
def start
Definition: IOTest.py:97
System::ProcessTime::kernelTime
TimeValueType kernelTime() const
Retrieve the kernel time in the requested unit.
Definition: Timing.h:158
std::string
STL class.
IChronoSvc::USER
Definition: IChronoSvc.h:46
ChronoEntity::m_start
System::ProcessTime m_start
start stamp for current measurement of process times
Definition: ChronoEntity.h:163
ChronoEntity::m_delta
System::ProcessTime m_delta
delta process times
Definition: ChronoEntity.h:161
ChronoEntity::kRMSTime
double kRMSTime() const
r.m.s Kernel Time
Definition: ChronoEntity.h:237
ChronoEntity::eMaximalTime
double eMaximalTime() const
maximal measurement for elapsed time
Definition: ChronoEntity.h:205
ChronoEntity::uTotalTime
double uTotalTime() const
total user time
Definition: ChronoEntity.h:209
System::microSec
Definition: Timing.h:57
GaudiPython.HistoUtils.mean
mean
Definition: HistoUtils.py:875
ChronoEntity::nOfMeasurements
unsigned long nOfMeasurements() const
number of chrono measurements
Definition: ChronoEntity.h:181
System::TimeType
TimeType
Time type for conversion.
Definition: Timing.h:57
ChronoEntity::eMinimalTime
double eMinimalTime() const
minimal measurement for elapsed time
Definition: ChronoEntity.h:193
gaudirun.type
type
Definition: gaudirun.py:142
ChronoEntity::m_kernel
StatEntity m_kernel
the actual storage of "kernel" time
Definition: ChronoEntity.h:167
ChronoEntity::uMeanTime
double uMeanTime() const
average User Time
Definition: ChronoEntity.h:229
ChronoEntity::kMeanTime
double kMeanTime() const
average Kernel Time
Definition: ChronoEntity.h:225
System::ProcessTime
Simple class to hold the time information of a process.
Definition: Timing.h:146
ChronoEntity::eTotalTime
double eTotalTime() const
total Elapsed time
Definition: ChronoEntity.h:217
IChronoSvc::ELAPSED
Definition: IChronoSvc.h:46
Timing.h
IChronoSvc::ChronoTime
double ChronoTime
Type of the delta-time.
Definition: IChronoSvc.h:39
IChronoSvc::UNKNOWN
Definition: IChronoSvc.h:44
ChronoEntity::kTotalTime
double kTotalTime() const
total Kernel time
Definition: ChronoEntity.h:213
StatEntity.h
ChronoEntity::uMaximalTime
double uMaximalTime() const
maximal measurement for user time
Definition: ChronoEntity.h:197
ChronoEntity::kMinimalTime
double kMinimalTime() const
minimal measurement for kernel time
Definition: ChronoEntity.h:189
ChronoEntity::totalTime
double totalTime() const
total time
Definition: ChronoEntity.h:221
IChronoSvc::ChronoType
ChronoType
Definition: IChronoSvc.h:46
ChronoEntity::TimeUnit
static const System::TimeType TimeUnit
internal unit used for the system time conversion (microseconds)
Definition: ChronoEntity.h:171
ChronoEntity::operator<
friend bool operator<(ChronoEntity const &lhs, ChronoEntity const &rhs)
comparison operator
Definition: ChronoEntity.h:89
ChronoEntity::eMeanTime
double eMeanTime() const
average Elapsed Time
Definition: ChronoEntity.h:233
IChronoSvc.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
ChronoEntity::kMaximalTime
double kMaximalTime() const
maximal measurement for kernel time
Definition: ChronoEntity.h:201
ChronoEntity::status
IChronoSvc::ChronoStatus status() const
return the status of chrono
Definition: ChronoEntity.h:177
ChronoEntity::outputElapsedTime
std::string outputElapsedTime() const
print the chrono ;
Definition: ChronoEntity.cpp:95
ChronoEntity::uRMSTime
double uRMSTime() const
r.m.s User Time
Definition: ChronoEntity.h:241
ChronoEntity::outputUserTime
std::string outputUserTime() const
print the chrono ;
Definition: ChronoEntity.cpp:82
ChronoEntity::outputSystemTime
std::string outputSystemTime() const
print the chrono ;
Definition: ChronoEntity.cpp:89
GaudiPython.HistoUtils.rms
rms
Definition: HistoUtils.py:879