2 #pragma warning( disable : 4786 )
46 : public
std::binary_function<
51 inline bool operator()
59 return ( ( 0 == e1 || 0 == e2 ) ?
true : (*e1)<(*e2) ) ;
66 :
public std::binary_function<
67 const std::pair<const StatEntity*,const IChronoStatSvc::StatTag*> ,
68 const std::pair<const StatEntity*,const IChronoStatSvc::StatTag*> , bool >
72 inline bool operator()
80 return ( 0 == se1 || 0 == se2 ) ?
true : (*se1)<(*se2) ;
95 , m_header (
" Counter | # | sum | mean/eff^* | rms/err^* | min | max |")
97 , m_format1 (
" %|-15.15s|%|17t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" )
99 , m_format2 (
"*%|-15.15s|%|17t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |" )
101 , m_useEffFormat (
true )
104 declareProperty (
"ChronoPrintOutTable" ,
105 m_chronoTableFlag =
true );
107 declareProperty (
"ChronoDestinationCout" ,
108 m_chronoCoutFlag =
false );
110 declareProperty (
"ChronoPrintLevel" ,
114 declareProperty (
"ChronoTableToBeOrdered" ,
115 m_chronoOrderFlag =
true );
117 declareProperty (
"PrintUserTime" ,
118 m_printUserTime =
true );
120 declareProperty (
"PrintSystemTime" ,
121 m_printSystemTime =
false );
123 declareProperty (
"PrintEllapsedTime" ,
124 m_printEllapsedTime =
false );
127 declareProperty (
"StatPrintOutTable" ,
128 m_statTableFlag =
true );
130 declareProperty (
"StatDestinationCout" ,
131 m_statCoutFlag =
false );
133 declareProperty (
"StatPrintLevel" ,
137 declareProperty (
"StatTableToBeOrdered" ,
138 m_statOrderFlag =
true );
142 declareProperty (
"NumberOfSkippedEventsForMemStat" ,
143 m_numberOfSkippedEventsForMemStat = -1 ) ;
145 declareProperty(
"AsciiStatsOutputFile",
146 m_statsOutFileName =
"",
147 "Name of the output file storing the stats. If empty, no"
148 " statistics will be saved (default)" );
151 (
"StatTableHeader" , m_header ,
152 "The header row for the output Stat-table" ) ;
154 (
"RegularRowFormat" , m_format1 ,
155 "The format for the regular row in the output Stat-table" ) ;
157 (
"EfficiencyRowFormat" , m_format2 ,
158 "The format for the regular row in the output Stat-table" ) ;
160 (
"UseEfficiencyRowFormat" , m_useEffFormat ,
161 "Use the special format for printout of efficiency counters" ) ;
164 (
"PerEventFile", m_perEventFile=
"",
165 "File name for per-event deltas" );
199 if (!
m_ofd.is_open()) {
200 log <<
MSG::ERROR <<
"unable to open per-event output file \""
213 log <<
MSG::INFO <<
" Number of skipped events for MemStat"
248 std::string local =
name()+
".finalize()";
255 if (
m_ofd.is_open()) {
259 TimeMap::const_iterator itr;
262 alg.erase(alg.length()-8,8);
264 std::vector<IChronoSvc::ChronoTime>::const_iterator itt;
265 for (itt=itr->second.begin(); itt!=itr->second.end(); ++itt) {
266 m_ofd <<
" " << (
long int)(*itt);
285 std::cout << stars << std::endl;
286 std::cout << local <<
" The Final CPU consumption (Chrono) Table "
288 std::cout << stars << std::endl;
295 <<
" The Final CPU consumption ( Chrono ) Table "
301 typedef std::pair<ChronoEntity*,const ChronoTag*> MPair;
302 typedef std::vector<MPair> MCont;
306 { tmpCont.push_back( MPair( &(it->second) , &(it->first) ) ) ; }
309 { std::sort( tmpCont.begin() ,
315 for( MCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
318 ChronoEntity* entity = iter->first ;
if( 0 == entity ) { continue ; }
319 const ChronoTag* tag = iter->second ;
if( 0 == tag ) { continue ; }
324 { std::cout << *tag <<
"\t" << entity->
outputUserTime () << std::endl ; }
339 { std::cout << stars << std::endl; }
343 for( MCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
346 ChronoEntity* entity = iter->first ;
if( 0 == entity ) { continue ; }
347 const ChronoTag* tag = iter->second ;
if( 0 == tag ) { continue ; }
367 { std::cout << stars << std::endl; }
371 for( MCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
374 ChronoEntity* entity = iter->first ;
if( 0 == entity ) { continue ; }
375 const ChronoTag* tag = iter->second ;
if( 0 == tag ) { continue ; }
415 (
const ChronoTag& chronoTag )
440 return m_chronoEntities[ chronoTag ].delta( theType );
449 if( m_printUserTime ) {
451 << m_chronoEntities[ chronoTag ].outputUserTime ()
454 if( m_printSystemTime ) {
456 << m_chronoEntities[ chronoTag ].outputSystemTime()
466 {
return m_chronoEntities[ chronoTag ].status(); }
474 StatMap::iterator theIter=m_statEntities.find(statTag);
478 if (theIter==m_statEntities.end()){
480 StatEntity& theSe = m_statEntities[ statTag ];
487 theStat=&((*theIter).second);
490 theStat->
addFlag ( statFlag ) ;
499 log << (
MSG::Level) m_statPrintLevel << m_statEntities[ statTag ] <<
endmsg;
511 ChronoMap::const_iterator it = m_chronoEntities.find ( t ) ;
512 if ( m_chronoEntities.end() != it ) {
return &(it->second) ; }
525 StatMap::const_iterator it = m_statEntities.find ( t ) ;
526 if ( m_statEntities.end() != it ) {
return &(it->second) ; }
535 std::ios_base::out | std::ios_base::trunc );
539 <<
"Could not open the output file for writing chrono statistics ["
545 out << std::scientific << std::setprecision(8) ;
549 typedef std::pair<ChronoEntity*, const ChronoTag*> MPair;
550 typedef std::vector<MPair> MCont;
555 chronos.push_back( MPair( &(it->second) , &(it->first) ) ) ;
559 std::sort( chronos.begin() ,
564 for( MCont::iterator iter = chronos.begin() ;
565 chronos.end() != iter;
569 if( 0 == entity ) { continue ; }
572 if( 0 == tag ) { continue ; }
575 out <<
"\n[" << *tag <<
"]\n";
578 out <<
"cpu_user_total = " << entity->
uTotalTime() <<
"\n";
579 out <<
"cpu_user_min = " << entity->
uMinimalTime() <<
"\n";
580 out <<
"cpu_user_mean = " << entity->
uMeanTime() <<
"\n";
581 out <<
"cpu_user_RMS = " << entity->
uRMSTime() <<
"\n";
582 out <<
"cpu_user_max = " << entity->
uMaximalTime() <<
"\n";
587 out <<
"cpu_system_total = " << entity->
kTotalTime() <<
"\n";
588 out <<
"cpu_system_min = " << entity->
kMinimalTime() <<
"\n";
589 out <<
"cpu_system_mean = " << entity->
kMeanTime() <<
"\n";
590 out <<
"cpu_system_RMS = " << entity->
kRMSTime() <<
"\n";
591 out <<
"cpu_system_max = " << entity->
kMaximalTime() <<
"\n";
596 out <<
"cpu_real_total = " << entity->
eTotalTime() <<
"\n";
597 out <<
"cpu_real_min = " << entity->
eMinimalTime() <<
"\n";
598 out <<
"cpu_real_mean = " << entity->
eMeanTime() <<
"\n";
599 out <<
"cpu_real_RMS = " << entity->
eRMSTime() <<
"\n";
600 out <<
"cpu_real_max = " << entity->
eMaximalTime() <<
"\n";
621 std::cout << stars << std::endl;
622 std::cout <<
" The Final stat Table "
624 std::cout << stars << std::endl;
636 typedef std::pair<const StatEntity*,const StatTag*> SPair;
637 typedef std::vector<SPair> SCont;
641 { tmpCont.push_back( SPair( &(it->second) , &(it->first) ) ) ; }
644 { std::sort( tmpCont.begin() ,
655 for ( SCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
659 if ( 0 == entity ) { continue ; }
660 const StatTag* tag = iter->second ;
661 if ( 0 == tag ) { continue ; }
690 if (!
m_ofd.is_open())
return;
692 TimeMap::iterator
itm;
693 ChronoMap::const_iterator itr;
695 if (itr->first.find(
":Execute") == std::string::npos)
continue;
704 m_perEvtTime[itr->first] = std::vector<IChronoSvc::ChronoTime>();
std::string outputElapsedTime() const
print the chrono ;
bool m_useEffFormat
flag to use the special "efficiency" format
int m_intStatPrintLevel
level of info printing
double kMaximalTime() const
maximal measurement for kernel time
Definition of the MsgStream class used to transmit messages.
virtual StatusCode initialize()
Implementation of IService::initialize()
void handle(const Incident &incident)
Inform that a new incident has occurred.
double uMinimalTime() const
minimal measurement for user time
bool m_chronoOrderFlag
flag for formattion the final statistic table
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
bool m_printUserTime
flag for printing User quantities
double uTotalTime() const
total user time
virtual ChronoStatus chronoStatus(const IChronoStatSvc::ChronoTag &chronoTag)
Implementation of IChronoStatSvc::chronoStatus.
StatMap m_statEntities
stat part
bool m_printEllapsedTime
flag for printing Ellapsed quantities
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
double StatFlag
the actual value type used for Stat
std::string m_header
the header row
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
double kTotalTime() const
total Kernel time
StringProperty m_statsOutFileName
Name of the output file where we'll dump the stats.
double uRMSTime() const
r.m.s User Time
virtual void statPrint(const IChronoStatSvc::ChronoTag &statTag)
prints (using message service) info about statistical entity, tagged by its name
double kMinimalTime() const
minimal measurement for kernel time
double eMinimalTime() const
minimal measurement for elapsed time
double kRMSTime() const
r.m.s Kernel Time
long m_numberOfSkippedEventsForMemStat
std::string outputSystemTime() const
print the chrono ;
IChronoSvc::ChronoStatus start()
start the current chrono
std::string m_format2
format for "efficiency" statistical printout rows
bool isFailure() const
Test for a status code of FAILURE.
bool m_chronoTableFlag
flag for printing the final table
virtual const ChronoEntity * chronoStop(const IChronoStatSvc::ChronoTag &chronoTag)
Implementation of IChronoStatSvc::chronoStop.
#define DECLARE_COMPONENT(type)
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
GAUDI_API std::string formatAsTableRow(const StatEntity &counter, const bool flag, const std::string &format1=" |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
int m_intChronoPrintLevel
level of info printing
void setnEntriesBeforeReset(unsigned long nEntriesBeforeReset)
DR specify number of entry before reset.
The IChronoStatSvc is the interface implemented by the ChronoStatService.
double kMeanTime() const
average Kernel Time
virtual void stat(const IChronoStatSvc::StatTag &statTag, const IChronoStatSvc::StatFlag &statFlag)
Implementation of IChronoStatSvc::stat add statistical information to the entity , tagged by its name.
const std::string EndEvent
Processing of the last event has finished.
double eMeanTime() const
average Elapsed Time
void saveStats()
dump the statistics into an ASCII file for offline processing
bool m_statOrderFlag
flag for formattion the final statistic table
This class is used for returning status codes from appropriate routines.
std::string ChronoTag
the actual type of identifier for Chrono objects
void clear(STATE_TYPE _i=std::ios_base::failbit)
virtual ~ChronoStatSvc()
Destructor.
double eRMSTime() const
r.m.s Elapsed Time
virtual const ChronoEntity * chrono(const IChronoStatSvc::ChronoTag &t) const
extract the chrono entity for the given tag (name)
bool m_statTableFlag
flag for printing the final table
const TYPE & value() const
explicit conversion
unsigned long addFlag(const double Flag)
add a flag
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
virtual const std::string & name() const
Retrieve name of the service.
MSG::Level m_chronoPrintLevel
virtual void chronoPrint(const IChronoStatSvc::ChronoTag &chronoTag)
Implementation of IChronoStatSvc::chronoPrint.
double ChronoTime
Type of the delta-time.
double uMeanTime() const
average User Time
std::string outputUserTime() const
print the chrono ;
bool m_statCoutFlag
flag for destination of the t he final table
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
bool m_printSystemTime
flag for printing System quantities
double eMaximalTime() const
maximal measurement for elapsed time
Base class for all Incidents (computing events).
std::string m_perEventFile
Templated class to add the standard messaging functionalities.
virtual IChronoStatSvc::ChronoTime chronoDelta(const IChronoStatSvc::ChronoTag &chronoTag, IChronoStatSvc::ChronoType theType)
Implementation of IchronoStatSvc::chronoDelta.
virtual StatusCode finalize()
Implementation of IService::finalize()
virtual ChronoEntity * chronoStart(const IChronoStatSvc::ChronoTag &chronoTag)
Implementation of IChronoStatSvc::chronoStart.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
unsigned long nOfMeasurements() const
number of chrono measurements
MSG::Level m_statPrintLevel
bool m_chronoCoutFlag
flag for destination of the the final table
The basic counter used for Monitoring purposes.
std::string StatTag
the actual identificator of Stat
IChronoSvc::ChronoStatus stop()
stop the chrono
double uMaximalTime() const
maximal measurement for user time
double eTotalTime() const
total Elapsed time
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
std::string m_format1
format for regular statistical printout rows
The Chrono & Stat Sservice: service implements the IChronoStatSvc interface and provides the basic ch...
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
ChronoMap m_chronoEntities
chrono part