Go to the documentation of this file.
53 template <
typename S,
typename T>
54 inline bool operator()(
const std::pair<S*, T*>&
p1,
const std::pair<S*, T*>&
p2 )
const {
70 const IChronoStatSvc::ChronoTag&
key = item.first;
80 const IChronoStatSvc::StatTag&
key = item.first;
98 if ( !
m_ofd.is_open() ) {
104 error() <<
"Unable to find IncidentSvc" <<
endmsg;
107 ii->addListener(
this, IncidentType::EndEvent );
124 std::string local =
name() +
".finalize()";
131 if (
m_ofd.is_open() ) {
134 m_ofd << itr.first.substr( 0, itr.first.length() - 8 ) <<
" ";
135 for (
const auto& itt : itr.second ) {
m_ofd <<
" " << (
long int)( itt ); }
149 std::cout << stars << std::endl;
150 if (
isMT() ) { std::cout <<
"WARNING: MT job; statistics are unreliable" << std::endl; }
151 std::cout << local <<
" The Final CPU consumption (Chrono) Table "
153 std::cout << stars << std::endl;
163 std::vector<std::pair<ChronoEntity*, const ChronoTag*>> tmpCont;
165 for (
auto& it :
m_chronoEntities ) { tmpCont.emplace_back( &it.second, &it.first ); }
170 for (
auto iter = tmpCont.begin(); tmpCont.end() != iter; ++iter ) {
173 if ( !entity ) {
continue; }
174 const ChronoTag* tag = iter->second;
175 if ( !tag ) {
continue; }
181 std::cout << *tag <<
"\t" << entity->
outputUserTime() << std::endl;
194 std::cout << stars << std::endl;
199 for (
auto iter = tmpCont.begin(); tmpCont.end() != iter; ++iter ) {
202 if ( !entity ) {
continue; }
203 const ChronoTag* tag = iter->second;
204 if ( !tag ) {
continue; }
223 std::cout << stars << std::endl;
228 for (
const auto& i : tmpCont ) {
231 if ( !entity ) {
continue; }
232 const ChronoTag* tag = i.second;
233 if ( !tag ) {
continue; }
252 std::cout << stars << std::endl;
294 IChronoStatSvc::ChronoType theType ) {
314 void ChronoStatSvc::stat(
const IChronoStatSvc::StatTag& statTag,
const IChronoStatSvc::StatFlag& statFlag ) {
325 theStat = &theIter->second;
345 auto lock = std::scoped_lock{
m_mutex };
366 info() <<
"Could not open the output file for writing chrono statistics [" <<
m_statsOutFileName.
value() <<
"]"
371 out << std::scientific << std::setprecision( 8 );
375 std::vector<std::pair<const ChronoEntity*, const ChronoTag*>> chronos;
377 auto lock = std::scoped_lock{
m_mutex };
380 []( ChronoMap::const_reference i ) {
return std::make_pair( &i.second, &i.first ); } );
387 for (
const auto& iter : chronos ) {
390 if ( !entity ) {
continue; }
392 const ChronoTag* tag = iter.second;
393 if ( !tag ) {
continue; }
396 out <<
"\n[" << *tag <<
"]\n";
401 out <<
"cpu_user_mean = " << entity->
uMeanTime() <<
"\n";
402 out <<
"cpu_user_RMS = " << entity->
uRMSTime() <<
"\n";
408 out <<
"cpu_system_total = " << entity->
kTotalTime() <<
"\n";
410 out <<
"cpu_system_mean = " << entity->
kMeanTime() <<
"\n";
411 out <<
"cpu_system_RMS = " << entity->
kRMSTime() <<
"\n";
419 out <<
"cpu_real_mean = " << entity->
eMeanTime() <<
"\n";
420 out <<
"cpu_real_RMS = " << entity->
eRMSTime() <<
"\n";
433 error() <<
"Cannot retrieve HiveWhiteBoardSvc";
437 if ( wb && wb->getNumberOfStores() > 1 ) {
isMT =
true; }
453 std::cout << stars << std::endl;
454 if (
isMT() ) { std::cout <<
"WARNING: MT job; statistics are unreliable" << std::endl; }
455 std::cout <<
" The Final stat Table " << (
m_statOrderFlag ?
"(ordered)" :
"(not ordered)" ) << std::endl;
456 std::cout << stars << std::endl;
467 typedef std::pair<const StatEntity*, const StatTag*> SPair;
468 typedef std::vector<SPair> SCont;
471 []( StatMap::const_reference i ) {
return std::make_pair( &i.second, &i.first ); } );
482 for (
const auto& iter : tmpCont ) {
485 if ( !entity ) {
continue; }
486 const StatTag* tag = iter.second;
487 if ( !tag ) {
continue; }
492 std::ostringstream ost;
501 std::cout << stars << std::endl;
511 if ( !
m_ofd.is_open() )
return;
513 auto lock = std::scoped_lock{
m_mutex };
515 if ( itr.first.find(
":Execute" ) == std::string::npos )
continue;
Gaudi::Property< std::string > m_header
Gaudi::Property< bool > m_printSystemTime
Gaudi::Property< bool > m_chronoOrderFlag
StatusCode initialize() override
double eMinimalTime() const
minimal measurement for elapsed time
double uMinimalTime() const
minimal measurement for user time
IChronoSvc::ChronoStatus stop()
stop the chrono
double eRMSTime() const
r.m.s Elapsed Time
ChronoEntity & getEntity(const ChronoTag &chronoTag)
ChronoMap m_chronoEntities
chrono part
StatusCode finalize() override
Implementation of IService::finalize()
backward compatible StatEntity class.
Gaudi::Property< bool > m_statCoutFlag
double eMeanTime() const
average Elapsed Time
ChronoStatus chronoStatus(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStatus.
IChronoSvc::ChronoTime delta(IChronoSvc::ChronoType type) const
return the last delta-time of type "type"
StatMap m_statEntities
stat part
double eTotalTime() const
total Elapsed time
double kMinimalTime() const
minimal measurement for kernel time
void merge(const ChronoStatSvc &css)
Compound assignment operator.
StatusCode finalize() override
void stat(const IChronoStatSvc::StatTag &statTag, const IChronoStatSvc::StatFlag &statFlag) override
Implementation of IChronoStatSvc::stat add statistical information to the entity ,...
IChronoSvc::ChronoStatus start()
start the current chrono
IChronoStatSvc::ChronoTime chronoDelta(const IChronoStatSvc::ChronoTag &chronoTag, IChronoStatSvc::ChronoType theType) override
Implementation of IchronoStatSvc::chronoDelta.
unsigned long nOfMeasurements() const
number of chrono measurements
const ChronoEntity * chronoStop(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStop.
double uMeanTime() const
average User Time
std::string outputSystemTime() const
print the chrono ;
void statPrint(const IChronoStatSvc::ChronoTag &statTag) override
prints (using message service) info about statistical entity, tagged by its name
void saveStats()
dump the statistics into an ASCII file for offline processing
Gaudi::Property< bool > m_printUserTime
std::mutex m_mutex
Mutex protecting m_chronoEntities.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
T * get() const
Allow non const access to the service, even from a const handle...
const std::string & name() const override
Retrieve name of the service
std::ostream & print(std::ostream &o, bool tableFormat, std::string_view name, bool flag=true, std::string_view fmtHead="%|-48.48s|%|27t|") const
double kRMSTime() const
r.m.s Kernel Time
double kTotalTime() const
total Kernel time
std::string outputElapsedTime() const
print the chrono ;
std::string outputUserTime() const
print the chrono ;
Gaudi::Property< bool > m_printEllapsedTime
Gaudi::Property< bool > m_chronoTableFlag
const ValueType & value() const
Gaudi::Property< bool > m_useEffFormat
void clear(STATE_TYPE _i=std::ios_base::failbit)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
IChronoSvc::ChronoStatus status() const
return the status of chrono
MSG::Level m_chronoPrintLevel
level of info printing
StatusCode retrieve(T *&service) const override
Do the real retrieval of the Service.
HepRndm::Engine< TripleRand > e2
double kMaximalTime() const
maximal measurement for kernel time
double uRMSTime() const
r.m.s User Time
unsigned long addFlag(const double v)
ServiceHandle< IInterface > m_hiveWhiteBoardSvc
bool operator()(const std::pair< S *, T * > &p1, const std::pair< S *, T * > &p2) const
Gaudi::Property< bool > m_statTableFlag
ChronoEntity * chronoStart(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStart.
constexpr static const auto SUCCESS
Gaudi::Property< bool > m_statOrderFlag
#define DECLARE_COMPONENT(type)
Gaudi::Property< bool > m_chronoCoutFlag
MSG::Level m_statPrintLevel
level of info printing
void handle(const Incident &incident) override
StatusCode initialize() override
Implementation of IService::initialize()
double kMeanTime() const
average Kernel Time
Gaudi::Property< std::string > m_perEventFile
void chronoPrint(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoPrint.
double uMaximalTime() const
maximal measurement for user time
constexpr static const auto FAILURE
Gaudi::Property< std::string > m_statsOutFileName
double eMaximalTime() const
maximal measurement for elapsed time
const ChronoEntity * chrono(const IChronoStatSvc::ChronoTag &t) const override
extract the chrono entity for the given tag (name)
double uTotalTime() const
total user time
constexpr struct CompareFirstOfPointerPair_t CompareFirstOfPointerPair
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator