1 #define GAUDIKERNEL_CHRONOENTITY_CPP 1
21 #include "boost/format.hpp"
32 const double microsecond = 1 ;
33 const double millisecond = 1000 * microsecond ;
34 const double second = 1000 * millisecond ;
35 const double minute = 60 * second ;
36 const double hour = 60 * minute ;
37 const double day = 24 * hour ;
38 const double week = 7 * day ;
39 const double month = 30 * day ;
40 const double year = 365 * day ;
41 const double nanosecond = 0.001 * microsecond ;
93 std::string res (
"Time User : ") ;
107 std::string res (
"Time System : ") ;
120 std::string res (
"TimeElapsed: ") ;
133 (
const double total ,
134 const double minimal ,
137 const double maximal ,
138 const unsigned long number )
const
144 long double unit = 1.0 ;
146 if ( total / microsecond < 500 )
147 { unit = microsecond ; fmt %
" [us]" ; }
148 else if( total / millisecond < 500 )
149 { unit = millisecond ; fmt %
" [ms]" ; }
150 else if( total / second < 500 )
151 { unit = second ; fmt %
" [s]" ; }
152 else if( total / minute < 500 )
153 { unit = minute ; fmt %
"[min]" ; }
154 else if( total / hour < 500 )
155 { unit = hour ; fmt %
" [h]" ; }
156 else if( total / day < 10 )
157 { unit = day ; fmt %
"[day]" ; }
158 else if( total / week < 5 )
159 { unit = week ; fmt %
" [w]" ; }
160 else if( total / month < 20 )
161 { unit = month ; fmt %
"[mon]" ; }
163 { unit = year ; fmt %
" [y]" ; }
165 fmt % (double) (total / unit) % number;
170 boost::format fmt1(
"Ave/Min/Max=%2$5.3g(+-%3$5.3g)/%4$5.3g/%5$5.3g%1$s");
171 if ( mean / microsecond < 500 )
172 { unit = microsecond ; fmt1 %
" [us]" ; }
173 else if( mean / millisecond < 500 )
174 { unit = millisecond ; fmt1 %
" [ms]" ; }
175 else if( mean / second < 500 )
176 { unit = second ; fmt1 %
" [s]" ; }
177 else if( mean / minute < 500 )
178 { unit = minute ; fmt1 %
"[min]" ; }
179 else if( mean / hour < 500 )
180 { unit = hour ; fmt1 %
" [h]" ; }
181 else if( mean / day < 10 )
182 { unit = day ; fmt1 %
"[day]" ; }
183 else if( mean / week < 5 )
184 { unit = week ; fmt1 %
" [w]" ; }
185 else if( mean / month < 20 )
186 { unit = month ; fmt1 %
"[mon]" ; }
188 { unit = year ; fmt1 %
" [y]" ; }
190 fmt1 % (double) ( mean / unit ) % (double) ( rms / unit )
191 % (double) ( minimal / unit ) % (double) ( maximal / unit );
206 ( &e ==
this ) ?
false :
227 const std::string& fmt ,
232 using namespace boost::io ;
233 _fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
235 double _unit = microsecond ;
247 default : _unit = microsecond ; break ;
256 default : stat = &m_user ; break ;
260 % ( stat -> nEntries () )
261 % ( stat -> flag () / _unit )
262 % ( stat -> flagMean () / _unit )
263 % ( stat -> flagRMS () / _unit )
264 % ( stat -> flagMeanErr () / _unit )
265 % ( stat -> flagMin () / _unit )
266 % ( stat -> flagMax () / _unit ) ;
std::string outputElapsedTime() const
print the chrono ;
double kMaximalTime() const
maximal measurement for kernel time
double uMinimalTime() const
minimal measurement for user time
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
IChronoSvc::ChronoStatus m_status
current status of this chrono object;
double uTotalTime() const
total user time
StatEntity m_elapsed
the actual storage of "elapsed" time
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
TimeValueType kernelTime() const
Retrieve the kernel time in the requested unit.
double kTotalTime() const
total Kernel time
TimeValueType userTime() const
Retrieve the user time in the requested unit.
StatEntity m_user
the actual storage of "user" time
double uRMSTime() const
r.m.s User Time
double kMinimalTime() const
minimal measurement for kernel time
double eMinimalTime() const
minimal measurement for elapsed time
ChronoEntity()
default constructor
double kRMSTime() const
r.m.s Kernel Time
std::string outputSystemTime() const
print the chrono ;
IChronoSvc::ChronoStatus start()
start the current chrono
std::string outputTime(IChronoSvc::ChronoType typ, const std::string &fmt, System::TimeType unit) const
print the chrono according the format and units
System::ProcessTime m_start
start stamp for current measurement of process times
System::ProcessTime m_delta
delta process times
double kMeanTime() const
average Kernel Time
double eMeanTime() const
average Elapsed Time
TimeType
Time type for conversion.
StatEntity m_kernel
the actual storage of "kernel" time
double eRMSTime() const
r.m.s Elapsed Time
double uMeanTime() const
average User Time
std::string outputUserTime() const
print the chrono ;
std::string format(const double total, const double minimal, const double mean, const double rms, const double maximal, const unsigned long number) const
format
double totalTime() const
total time
bool operator<(const ChronoEntity &entity) const
comparison operator
TimeValueType elapsedTime() const
Retrieve the elapsed time in the requested unit.
GAUDI_API ProcessTime getProcessTime(long pid=-1)
Retrieve the process time data for a process.
double eMaximalTime() const
maximal measurement for elapsed time
static const System::TimeType TimeUnit
internal unit used for the system time conversion (microseconds)
unsigned long nOfMeasurements() const
number of chrono measurements
The basic counter used for Monitoring purposes.
IChronoSvc::ChronoStatus stop()
stop the chrono
double uMaximalTime() const
maximal measurement for user time
double eTotalTime() const
total Elapsed time
"Chrono"-related part of interface IChronoStatSvc