15#include <boost/format.hpp>
16#include <fmt/format.h>
23 constexpr double minute = 60 *
second;
24 constexpr double hour = 60 * minute;
25 constexpr double day = 24 * hour;
26 constexpr double week = 7 * day;
27 constexpr double month = 30 * day;
28 constexpr double year = 365 * day;
69 return "Time User : " +
73 return "Time System : " +
77 return "TimeElapsed: " +
80std::string
ChronoEntity::format(
const double total,
const double minimal,
const double mean,
const double rms,
81 const double maximal,
const unsigned long number )
const {
84 constexpr auto fmt =
"Tot={1:5.3g}{0:5} {3} #={2:3}";
85 constexpr auto stat_fmt =
"Ave/Min/Max={1:8.3g}(+-{2:8.3g})/{3:8.3g}/{4:8.3g}{0:5}";
87 static const std::array<std::tuple<int, double, std::string_view>, 9> tbl{ { { 500, microsecond,
" [us]" },
88 { 500, millisecond,
" [ms]" },
89 { 500, second,
" [s]" },
90 { 500, minute,
"[min]" },
91 { 500, hour,
" [h]" },
94 { 20, month,
"[mon]" },
95 { -1, year,
" [y]" } } };
97 auto i = find_if( begin( tbl ), prev( end( tbl ) ),
98 [&](
const auto& i ) {
return total < std::get<0>( i ) * std::get<1>( i ); } );
99 long double unit = std::get<1>( *i );
100 std::string_view unit_name = std::get<2>( *i );
102 auto stats = [&]() -> std::string {
104 auto i = find_if( begin( tbl ), prev( end( tbl ) ),
105 [&](
const auto& i ) {
return total < std::get<0>( i ) * std::get<1>( i ); } );
106 auto unit = std::get<1>( *i );
107 std::string_view unit_name = std::get<2>( *i );
108 return fmt::format( stat_fmt, unit_name, (
double)( mean / unit ), (
double)( rms / unit ),
109 (
double)( minimal / unit ), (
double)( maximal / unit ) );
115 return fmt::format( fmt, unit_name, (
double)( total / unit ), number, stats() );
135 boost::format _fmt( std::string{ fmt } );
137 using namespace boost::io;
138 _fmt.exceptions( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) );
139 double _unit = microsecond;
187 _fmt % ( stat->nEntries() )
188 % ( stat->
flag() / _unit )
std::string outputSystemTime() const
print the chrono ;
double kMaximalTime() const
maximal measurement for kernel time
std::string outputTime(IChronoSvc::ChronoType typ, std::string_view fmt, System::TimeType unit) const
print the chrono according the format and units
double kTotalTime() const
total Kernel time
System::ProcessTime m_start
start stamp for current measurement of process times
double eMinimalTime() const
minimal measurement for elapsed time
std::string format(const double total, const double minimal, const double mean, const double rms, const double maximal, const unsigned long number) const
format
IChronoSvc::ChronoStatus start()
start the current chrono
ChronoEntity()=default
default constructor
IChronoSvc::ChronoStatus stop()
stop the chrono
double eMeanTime() const
average Elapsed Time
double uMeanTime() const
average User Time
double uMaximalTime() const
maximal measurement for user time
unsigned long nOfMeasurements() const
number of chrono measurements
double uTotalTime() const
total user time
StatEntity m_elapsed
the actual storage of "elapsed" time
double uRMSTime() const
r.m.s User Time
static const System::TimeType TimeUnit
internal unit used for the system time conversion (microseconds)
StatEntity m_kernel
the actual storage of "kernel" time
double eMaximalTime() const
maximal measurement for elapsed time
System::ProcessTime m_delta
delta process times
double kMinimalTime() const
minimal measurement for kernel time
std::string outputElapsedTime() const
print the chrono ;
ChronoEntity & operator+=(const ChronoEntity &entity)
Compound assignment operator.
StatEntity m_user
the actual storage of "user" time
double kMeanTime() const
average Kernel Time
double uMinimalTime() const
minimal measurement for user time
double eTotalTime() const
total Elapsed time
double eRMSTime() const
r.m.s Elapsed Time
std::string outputUserTime() const
print the chrono ;
IChronoSvc::ChronoStatus m_status
current status of this chrono object;
double kRMSTime() const
r.m.s Kernel Time
backward compatible StatEntity class.
double flagMeanErr() const
constexpr double nanosecond
constexpr double millisecond
constexpr double microsecond
GAUDI_API ProcessTime getProcessTime(long pid=-1)
Retrieve the process time data for a process.
TimeType
Time type for conversion.