| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ChronoStatSvc Class Reference

The Chrono & Stat Sservice: service implements the IChronoStatSvc interface and provides the basic chronometry and some statistical counts needed by all applications. More...

`#include <ChronoStatSvc.h>`

Inheritance diagram for ChronoStatSvc:
[legend]
Collaboration diagram for ChronoStatSvc:
[legend]

## Public Types
typedef std::map < IChronoStatSvc::ChronoTag, ChronoEntity > | ChronoMap
| some useful typedefs
typedef std::map < IChronoStatSvc::StatTag, StatEntity > | StatMap
Public Types inherited from extends2< Service, IChronoStatSvc, IIncidentListener >
typedef extends2 | base_class
| Typedef to this class.
typedef extend_interfaces2 < IChronoStatSvc, IIncidentListener > | extend_interfaces_base
| Typedef to the base of this class.
typedef extend_interfaces_base::ext_iids | interfaces
| MPL set of all the implemented interfaces.
Public Types inherited from Service
typedef Gaudi::PluginService::Factory2 < IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging | base_class
Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 | base_class
| Typedef to this class.
typedef extend_interfaces3 < IService, IProperty, IStateful > | extend_interfaces_base
| Typedef to the base of this class.
typedef extend_interfaces_base::ext_iids | interfaces
| MPL set of all the implemented interfaces.
Public Types inherited from extend_interfaces3< I1, I2, I3 >
typedef mpl::fold< typename I1::iid::iids::type, typename mpl::fold< typename I2::iid::iids::type, typename I3::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type, mpl::insert< mpl::_1, mpl::_2 > >::type | ext_iids
| MPL set of interfaces extended by this one.
Public Types inherited from extend_interfaces2< I1, I2 >
typedef mpl::fold< typename I1::iid::iids::type, typename I2::iid::iids::type, mpl::insert< mpl::_1, mpl::_2 > >::type | ext_iids
| MPL set of interfaces extended by this one.

## Public Member Functions
virtual StatusCode | initialize ()
| Implementation of IService::initialize()
virtual StatusCode | finalize ()
| Implementation of IService::finalize()
virtual ChronoEntity * | chronoStart (const IChronoStatSvc::ChronoTag &chronoTag)
| Implementation of IChronoStatSvc::chronoStart.
virtual const ChronoEntity * | chronoStop (const IChronoStatSvc::ChronoTag &chronoTag)
| Implementation of IChronoStatSvc::chronoStop.
virtual IChronoStatSvc::ChronoTime | chronoDelta (const IChronoStatSvc::ChronoTag &chronoTag, IChronoStatSvc::ChronoType theType)
| Implementation of IchronoStatSvc::chronoDelta.
virtual void | chronoPrint (const IChronoStatSvc::ChronoTag &chronoTag)
| Implementation of IChronoStatSvc::chronoPrint.
virtual ChronoStatus | chronoStatus (const IChronoStatSvc::ChronoTag &chronoTag)
| Implementation of IChronoStatSvc::chronoStatus.
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.
virtual void | statPrint (const IChronoStatSvc::ChronoTag &statTag)
| prints (using message service) info about statistical entity, tagged by its name
virtual const ChronoEntity * | chrono (const IChronoStatSvc::ChronoTag &t) const
| extract the chrono entity for the given tag (name)
virtual const StatEntity * | stat (const IChronoStatSvc::StatTag &t) const
| extract the stat entity for the given tag (name)
| ChronoStatSvc (const std::string &name, ISvcLocator *svcloc)
| Default constructor.
virtual | ~ChronoStatSvc ()
| Destructor.
void | handle (const Incident &incident)
Public Member Functions inherited from extends2< Service, IChronoStatSvc, IIncidentListener >
| extends2 (A1 a1, A2 a2, A3 a3)
| Templated constructor with 3 arguments.
| extends2 (A1 a1, A2 a2)
| Templated constructor with 2 arguments.
| extends2 (A1 a1)
| Templated constructor with 1 argument.
| extends2 ()
| Default constructor.
virtual void * | i_cast (const InterfaceID &tid) const
| Implementation of IInterface::i_cast.
virtual StatusCode | queryInterface (const InterfaceID &ti, void **pp)
| Implementation of IInterface::queryInterface.
virtual std::vector< std::string > | getInterfaceNames () const
| Implementation of IInterface::getInterfaceNames.
virtual | ~extends2 ()
| Virtual destructor.
Public Member Functions inherited from Service
virtual unsigned long | release ()
| Release Interface instance.
virtual const std::string & | name () const
| Retrieve name of the service.
virtual StatusCode | configure ()
virtual StatusCode | start ()
virtual StatusCode | stop ()
virtual StatusCode | terminate ()
virtual Gaudi::StateMachine::State | FSMState () const
virtual Gaudi::StateMachine::State | targetFSMState () const
virtual StatusCode | reinitialize ()
virtual StatusCode | restart ()
virtual StatusCode | sysInitialize ()
| Initialize Service.
virtual StatusCode | sysStart ()
| Initialize Service.
virtual StatusCode | sysStop ()
| Initialize Service.
virtual StatusCode | sysFinalize ()
| Finalize Service.
virtual StatusCode | sysReinitialize ()
| Re-initialize the Service.
virtual StatusCode | sysRestart ()
| Re-initialize the Service.
virtual StatusCode | setProperty (const Property &p)
virtual StatusCode | setProperty (const std::string &s)
virtual StatusCode | setProperty (const std::string &n, const std::string &v)
virtual StatusCode | getProperty (Property *p) const
virtual const Property & | getProperty (const std::string &name) const
virtual StatusCode | getProperty (const std::string &n, std::string &v) const
virtual const std::vector < Property * > & | getProperties () const
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value
| Service (const std::string &name, ISvcLocator *svcloc)
| Standard Constructor.
SmartIF< ISvcLocator > & | serviceLocator () const
| Retrieve pointer to service locator.
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job.
template<class T >
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.
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist.
template<class T >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property.
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties.
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
| CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
| Templated constructor with 3 arguments.
| CommonMessaging (const A1 &a1, const A2 &a2)
| Templated constructor with 2 arguments.
| CommonMessaging (const A1 &a1)
| Templated constructor with 1 argument.
| CommonMessaging ()
| Default constructor.
virtual | ~CommonMessaging ()
| Virtual destructor.
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service.
MsgStream & | msgStream () const
| Return an uninitialized MsgStream.
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts.
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL)
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING)
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO)
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG)
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO)
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream
Public Member Functions inherited from extend_interfaces2< I1, I2 >
virtual | ~extend_interfaces2 ()
| Virtual destructor.

## Protected Member Functions
void | printStats ()

## Private Types
typedef std::map< ChronoTag, std::vector < IChronoSvc::ChronoTime > > | TimeMap

## Private Member Functions
| ChronoStatSvc ()
| ChronoStatSvc (const ChronoStatSvc &)
ChronoStatSvc & | operator= (const ChronoStatSvc &)
void | saveStats ()
| dump the statistics into an ASCII file for offline processing

## Private Attributes
ChronoMap | m_chronoEntities
| chrono part
int | m_intChronoPrintLevel
| level of info printing
MSG::Level | m_chronoPrintLevel
bool | m_chronoTableFlag
| flag for printing the final table
bool | m_chronoCoutFlag
| flag for destination of the the final table
bool | m_chronoOrderFlag
| flag for formattion the final statistic table
bool | m_printUserTime
| flag for printing User quantities
bool | m_printSystemTime
| flag for printing System quantities
bool | m_printEllapsedTime
| flag for printing Ellapsed quantities
long | m_numberOfSkippedEventsForMemStat
StatMap | m_statEntities
| stat part
int | m_intStatPrintLevel
| level of info printing
MSG::Level | m_statPrintLevel
bool | m_statTableFlag
| flag for printing the final table
bool | m_statCoutFlag
| flag for destination of the t he final table
bool | m_statOrderFlag
| flag for formattion the final statistic table
StringProperty | m_statsOutFileName
| Name of the output file where we'll dump the stats.
std::string | m_header
| the header row
std::string | m_format1
| format for regular statistical printout rows
std::string | m_format2
| format for "efficiency" statistical printout rows
bool | m_useEffFormat
| flag to use the special "efficiency" format
TimeMap | m_perEvtTime
std::string | m_perEventFile
std::ofstream | m_ofd

## Additional Inherited Members
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel
| Service output level.
Gaudi::StateMachine::State | m_state
| Service state.
Gaudi::StateMachine::State | m_targetState
| Service state.

## Detailed Description

The Chrono & Stat Sservice: service implements the IChronoStatSvc interface and provides the basic chronometry and some statistical counts needed by all applications.

Author
  : Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru : December 1, 1999

Definition at line 33 of file ChronoStatSvc.h.

## Member Typedef Documentation

typedef std::map<IChronoStatSvc::ChronoTag,ChronoEntity> ChronoStatSvc::ChronoMap

some useful typedefs

Definition at line 38 of file ChronoStatSvc.h.

typedef std::map<IChronoStatSvc::StatTag,StatEntity> ChronoStatSvc::StatMap

Definition at line 39 of file ChronoStatSvc.h.

typedef std::map<ChronoTag, std::vector<IChronoSvc::ChronoTime> > ChronoStatSvc::TimeMap
| private

Definition at line 191 of file ChronoStatSvc.h.

## Constructor & Destructor Documentation

ChronoStatSvc::ChronoStatSvc | ( | const std::string & | name,
|  | ISvcLocator * | svcloc
| ) |  |

Default constructor.

Parameters

  name | service instance name
  svcloc | pointer to servcie locator

decide if the final printout should be performed

define the destination of the table to be printed

print level

if printout is to be performed, should one take care about some ordering?

if User Time information to be printed?

if System Time information to be printed?

if Ellapsed Time information to be printed?

deside if the final printout should be performed

define the destination of the table to be printed

print level

if printout is to be performed, should one take care about some ordering?

Definition at line 87 of file ChronoStatSvc.cpp.

: base_class( name , svcloc )
, m_chronoEntities ()
, m_chronoPrintLevel ( MSG::INFO )
, m_statEntities ()
, m_statPrintLevel ( MSG::INFO )
//
// the header row
, m_header ( " Counter | # | sum | mean/eff^* | rms/err^* | min | max |")
// format for regular statistical printout rows
, m_format1 ( " %|-15.15s|%|17t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" )
// format for "efficiency" statistical printout rows
, m_format2 ( "*%|-15.15s|%|17t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |" )
// flag to use the special "efficiency" format
, m_useEffFormat ( true )
{
declareProperty ( "ChronoPrintOutTable" ,
m_chronoTableFlag = true );
declareProperty ( "ChronoDestinationCout" ,
m_chronoCoutFlag = false );
declareProperty ( "ChronoPrintLevel" ,
m_intChronoPrintLevel = MSG::INFO );
declareProperty ( "ChronoTableToBeOrdered" ,
m_chronoOrderFlag = true );
declareProperty ( "PrintUserTime" ,
m_printUserTime = true );
declareProperty ( "PrintSystemTime" ,
m_printSystemTime = false );
declareProperty ( "PrintEllapsedTime" ,
m_printEllapsedTime = false );
declareProperty ( "StatPrintOutTable" ,
m_statTableFlag = true );
declareProperty ( "StatDestinationCout" ,
m_statCoutFlag = false );
declareProperty ( "StatPrintLevel" ,
m_intStatPrintLevel = MSG::INFO );
declareProperty ( "StatTableToBeOrdered" ,
m_statOrderFlag = true );
// specify the number of events to be skipped by the memory auditor
// in order to better spot memory leak
declareProperty ( "NumberOfSkippedEventsForMemStat" ,
m_numberOfSkippedEventsForMemStat = -1 ) ;
declareProperty( "AsciiStatsOutputFile",
m_statsOutFileName = "",
"Name of the output file storing the stats. If empty, no"
" statistics will be saved (default)" );
declareProperty
( "StatTableHeader" , m_header ,
"The header row for the output Stat-table" ) ;
declareProperty
( "RegularRowFormat" , m_format1 ,
"The format for the regular row in the output Stat-table" ) ;
declareProperty
( "EfficiencyRowFormat" , m_format2 ,
"The format for the regular row in the output Stat-table" ) ;
declareProperty
( "UseEfficiencyRowFormat" , m_useEffFormat ,
"Use the special format for printout of efficiency counters" ) ;
declareProperty
( "PerEventFile", m_perEventFile="",
"File name for per-event deltas" );
}

ChronoStatSvc::~ChronoStatSvc | ( |  | ) |
| virtual

Destructor.

Definition at line 171 of file ChronoStatSvc.cpp.

{
// clear the container of chrono entities
m_chronoEntities.clear();
// clear the container of stat entities
m_statEntities.clear();
}

ChronoStatSvc::ChronoStatSvc | ( |  | ) |
| private

ChronoStatSvc::ChronoStatSvc | ( | const ChronoStatSvc & |  | ) |
| private

## Member Function Documentation

const ChronoEntity * ChronoStatSvc::chrono | ( | const IChronoStatSvc::ChronoTag & | t | ) | const
| virtual

extract the chrono entity for the given tag (name)

See Also
  IChronoStatSvc

Parameters

  t | chrono tag(name)

Returns
  pointer to chrono entity

Definition at line 509 of file ChronoStatSvc.cpp.

{
ChronoMap::const_iterator it = m_chronoEntities.find ( t ) ;
if ( m_chronoEntities.end() != it ) { return &(it->second) ; }
return 0 ;
}

IChronoStatSvc::ChronoTime ChronoStatSvc::chronoDelta | ( | const IChronoStatSvc::ChronoTag & | chronoTag,
|  | IChronoStatSvc::ChronoType | theType
| ) |  |
| virtual

Implementation of IchronoStatSvc::chronoDelta.

See Also
  IChronoStatSvc

Definition at line 437 of file ChronoStatSvc.cpp.

{
return m_chronoEntities[ chronoTag ].delta( theType );
}

void ChronoStatSvc::chronoPrint | ( | const IChronoStatSvc::ChronoTag & | chronoTag | ) |
| virtual

Implementation of IChronoStatSvc::chronoPrint.

See Also
  IChronoStatSvc

Definition at line 446 of file ChronoStatSvc.cpp.

{
MsgStream log ( msgSvc() , chronoTag );
if( m_printUserTime ) {
log << (MSG::Level) m_chronoPrintLevel
<< m_chronoEntities[ chronoTag ].outputUserTime ()
<< endmsg;
}
if( m_printSystemTime ) {
log << (MSG::Level) m_chronoPrintLevel
<< m_chronoEntities[ chronoTag ].outputSystemTime()
<< endmsg;
}
}

ChronoEntity * ChronoStatSvc::chronoStart | ( | const IChronoStatSvc::ChronoTag & | chronoTag | ) |
| virtual

Implementation of IChronoStatSvc::chronoStart.

See Also
  IChronoStatSvc

Definition at line 415 of file ChronoStatSvc.cpp.

{
ChronoEntity& entity = m_chronoEntities [ chronoTag ] ;
entity.start() ;
return &entity ;
}

IChronoStatSvc::ChronoStatus ChronoStatSvc::chronoStatus | ( | const IChronoStatSvc::ChronoTag & | chronoTag | ) |
| virtual

Implementation of IChronoStatSvc::chronoStatus.

See Also
  IChronoStatSvc

Definition at line 465 of file ChronoStatSvc.cpp.

{ return m_chronoEntities[ chronoTag ].status(); }

const ChronoEntity * ChronoStatSvc::chronoStop | ( | const IChronoStatSvc::ChronoTag & | chronoTag | ) |
| virtual

Implementation of IChronoStatSvc::chronoStop.

See Also
  IChronoStatSvc

Definition at line 426 of file ChronoStatSvc.cpp.

{
ChronoEntity& entity = m_chronoEntities [ chronoTag ] ;
entity.stop() ;
return &entity ;
}

StatusCode ChronoStatSvc::finalize | ( |  | ) |
| virtual

Implementation of IService::finalize()

stop its own chrono

Is the final chrono table to be printed?

decoration

CONTINUE

CONTINUE

stop chrono (if it is still in RUNNING status)

print to std::cout

print to MsgStream

decoration

CONTINUE

CONTINUE

stop chrono (if it is still in RUNNING status)

print to std::cout

print to MsgStream

decoration

CONTINUE

CONTINUE

stop chrono (if it is still in RUNNING status)

print to std::cout

print to MsgStream

clear the temporary container

the final decoration

Is the final stat table to be printed?

< finalize the base class

Reimplemented from Service.

Definition at line 246 of file ChronoStatSvc.cpp.

{
std::string local = name()+".finalize()";
MsgStream main_log( msgSvc() , local );
chronoStop( name() ) ;
if (m_ofd.is_open()) {
MsgStream log(msgSvc(), name());
log << MSG::DEBUG << "writing per-event timing data to '" << m_perEventFile << "'" << endmsg;
std::string alg;
TimeMap::const_iterator itr;
for (itr=m_perEvtTime.begin(); itr != m_perEvtTime.end(); ++itr) {
alg = itr->first;
alg.erase(alg.length()-8,8);
m_ofd << alg << " ";
std::vector<IChronoSvc::ChronoTime>::const_iterator itt;
for (itt=itr->second.begin(); itt!=itr->second.end(); ++itt) {
m_ofd << " " << (long int)(*itt);
}
m_ofd << std::endl;
}
m_ofd.close();
}
if ( m_chronoTableFlag &&
!m_chronoEntities.empty() &&
( m_printUserTime || m_printSystemTime ) )
{
MsgStream log( msgSvc() , "*****Chrono*****" );
const std::string stars( ( m_chronoCoutFlag ) ? 126 : 100 , '*' );
if( m_chronoCoutFlag )
{
std::cout << stars << std::endl;
std::cout << local << " The Final CPU consumption (Chrono) Table "
<< ( m_chronoOrderFlag ? "(ordered)" : "(not ordered)" ) << std::endl;
std::cout << stars << std::endl;
}
else
{
log << (MSG::Level) m_chronoPrintLevel
<< stars << endmsg;
log << (MSG::Level) m_chronoPrintLevel
<< " The Final CPU consumption ( Chrono ) Table "
<< ( m_chronoOrderFlag ? "(ordered)" : "(not ordered)" ) << endmsg;
log << (MSG::Level) m_chronoPrintLevel << stars << endmsg;
}
{ // prepare container for printing
typedef std::pair<ChronoEntity*,const ChronoTag*> MPair;
typedef std::vector<MPair> MCont;
MCont tmpCont;
for( ChronoMap::iterator it = m_chronoEntities.begin() ;
m_chronoEntities.end() != it ; ++it )
{ tmpCont.push_back( MPair( &(it->second) , &(it->first) ) ) ; }
// sort it
if( m_chronoOrderFlag )
{ std::sort( tmpCont.begin() ,
tmpCont.end() ,
ComparePairOfChronoEntityAndChronoTag() ); }
// print User Time statistics
if( m_printUserTime )
{
for( MCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
{
//
ChronoEntity* entity = iter->first ; if( 0 == entity ) { continue ; }
const ChronoTag* tag = iter->second ; if( 0 == tag ) { continue ; }
entity->stop();
if ( m_chronoCoutFlag )
{ std::cout << *tag << "\t" << entity->outputUserTime () << std::endl ; }
else
{
MsgStream(msgSvc(), *tag)
<< m_chronoPrintLevel << entity->outputUserTime () << endmsg ;
}
//
}
}
if( m_printSystemTime )
{
if ( m_printUserTime && m_chronoCoutFlag )
{ std::cout << stars << std::endl; }
else if ( m_printUserTime && !m_chronoCoutFlag )
{ log << (MSG::Level) m_chronoPrintLevel << stars << endmsg; }
for( MCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
{
ChronoEntity* entity = iter->first ; if( 0 == entity ) { continue ; }
const ChronoTag* tag = iter->second ; if( 0 == tag ) { continue ; }
entity->stop();
if ( m_chronoCoutFlag )
{ std::cout << *tag << "\t" << entity->outputSystemTime() << std::endl ; }
else
{
MsgStream(msgSvc(), *tag)
<< m_chronoPrintLevel << entity->outputSystemTime() << endmsg ;
}
//
}
}
if( m_printEllapsedTime )
{
if ( ( m_printUserTime || m_printSystemTime ) && m_chronoCoutFlag )
{ std::cout << stars << std::endl; }
else if ( ( m_printUserTime || m_printSystemTime ) && !m_chronoCoutFlag )
{ log << (MSG::Level) m_chronoPrintLevel << stars << endmsg; }
for( MCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
{
ChronoEntity* entity = iter->first ; if( 0 == entity ) { continue ; }
const ChronoTag* tag = iter->second ; if( 0 == tag ) { continue ; }
entity->stop();
if ( m_chronoCoutFlag )
{ std::cout << *tag << "\t" << entity->outputElapsedTime() << std::endl ; }
else
{
MsgStream(msgSvc(), *tag)
<< m_chronoPrintLevel << entity->outputElapsedTime() << endmsg ;
}
//
}
}
tmpCont.clear();
}
if( m_chronoCoutFlag ) { std::cout << stars << std::endl; }
else { log << m_chronoPrintLevel << stars << endmsg; }
}
if ( m_statTableFlag ) { printStats () ; }
if ( !m_statsOutFileName.value().empty() ) {
saveStats();
}
main_log << MSG::INFO << " Service finalized successfully " << endmsg;
return Service::finalize();
}

void ChronoStatSvc::handle | ( | const Incident & | incident | ) |

Definition at line 688 of file ChronoStatSvc.cpp.

{
if (! m_ofd.is_open()) return;
TimeMap::iterator itm;
ChronoMap::const_iterator itr;
for (itr=m_chronoEntities.begin(); itr != m_chronoEntities.end(); ++itr) {
if (itr->first.find(":Execute") == std::string::npos) continue;
itm = m_perEvtTime.find(itr->first);
if (itm == m_perEvtTime.end()) {
// for when we move past gcc46....
// m_perEvtTime[itr->first] =
// std::vector<IChronoSvc::ChronoTime> {
// itr->second.delta(IChronoSvc::ELAPSED) };
m_perEvtTime[itr->first] = std::vector<IChronoSvc::ChronoTime>();
m_perEvtTime[itr->first].push_back(itr->second.delta(IChronoSvc::ELAPSED));
} else {
itm->second.push_back( itr->second.delta(IChronoSvc::ELAPSED) );
}
}
}

StatusCode ChronoStatSvc::initialize | ( |  | ) |
| virtual

Implementation of IService::initialize()

redefine some "properties"

start its own chrono

Reimplemented from Service.

Definition at line 181 of file ChronoStatSvc.cpp.

{
StatusCode sc = Service::initialize();
if ( sc.isFailure() ) return sc;
MsgStream log( msgSvc() , this->name() );
// Set my own properties
sc = setProperties();
if (sc.isFailure()) {
log << MSG::ERROR << "setting my properties" << endmsg;
return StatusCode::FAILURE;
}
// only add an EndEvent listener if per-event output requested
if (m_perEventFile != "") {
m_ofd.open(m_perEventFile.c_str());
if (!m_ofd.is_open()) {
log << MSG::ERROR << "unable to open per-event output file \""
<< m_perEventFile << "\"" << endmsg;
return StatusCode::FAILURE;
} else {
SmartIF<IIncidentSvc> ii(serviceLocator()->service("IncidentSvc"));
if (! ii) {
log << MSG::ERROR << "Unable to find IncidentSvc" << endmsg;
return StatusCode::FAILURE;
}
ii->addListener(this, IncidentType::EndEvent);
}
}
log << MSG::INFO << " Number of skipped events for MemStat"
<< m_numberOfSkippedEventsForMemStat << endmsg ;
m_statPrintLevel =
( MSG::FATAL < m_intStatPrintLevel ) ? MSG::FATAL :
( MSG::NIL > m_intStatPrintLevel ) ? MSG::NIL :
( MSG::Level ) m_intStatPrintLevel ;
m_chronoPrintLevel =
( MSG::FATAL < m_intChronoPrintLevel ) ? MSG::FATAL :
( MSG::NIL > m_intChronoPrintLevel ) ? MSG::NIL :
( MSG::Level ) m_intChronoPrintLevel ;
if( m_chronoTableFlag &&
!m_printUserTime &&
!m_printSystemTime &&
!m_printEllapsedTime ) { m_printUserTime = true ; }
if( m_printUserTime ||
m_printSystemTime ||
m_printEllapsedTime ) { m_chronoTableFlag = true ; }
chronoStart( name() ) ;
return StatusCode::SUCCESS;
}

ChronoStatSvc& ChronoStatSvc::operator= | ( | const ChronoStatSvc & |  | ) |
| private

void ChronoStatSvc::printStats | ( |  | ) |
| protected

nothing to print?

CONTINUE

CONTINUE

decoration

Definition at line 610 of file ChronoStatSvc.cpp.

{
if ( m_statEntities.empty() ) { return ; }
MsgStream log ( msgSvc() , "******Stat******" ) ;
const std::string stars( ( m_statCoutFlag ) ? 126 : 100 , '*' ) ;
if ( m_statCoutFlag )
{
std::cout << stars << std::endl;
std::cout << " The Final stat Table "
<< ( m_statOrderFlag ? "(ordered)" : "(not ordered)" ) << std::endl;
std::cout << stars << std::endl;
}
else
{
log << m_statPrintLevel << stars << endmsg;
log << m_statPrintLevel << " The Final stat Table "
<< ( m_statOrderFlag ? "(ordered)" : "(not ordered)" ) << endmsg;
log << m_statPrintLevel << stars << endmsg;
}
{
// prepare container for printing
typedef std::pair<const StatEntity*,const StatTag*> SPair;
typedef std::vector<SPair> SCont;
SCont tmpCont;
for( StatMap::const_iterator it = m_statEntities.begin();
it != m_statEntities.end(); it++ )
{ tmpCont.push_back( SPair( &(it->second) , &(it->first) ) ) ; }
// sort it
if ( m_statOrderFlag )
{ std::sort( tmpCont.begin() ,
tmpCont.end() ,
ComparePairOfStatEntityAndStatTag() ); }
{
// print the table header
if ( m_statCoutFlag ) { std::cout << m_header << std::endl ; }
else { log << m_statPrintLevel << m_header << endmsg ; }
}
// loop over counters and print them:
for ( SCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
{
const StatEntity* entity = iter->first ;
if ( 0 == entity ) { continue ; }
const StatTag* tag = iter->second ;
if ( 0 == tag ) { continue ; }
if ( m_statCoutFlag )
{
std::cout
<< Gaudi::Utils::formatAsTableRow
( *tag , *entity , m_useEffFormat , m_format1 , m_format2 )
<< std::endl;
}
else
{
log
<< m_statPrintLevel
<< Gaudi::Utils::formatAsTableRow
( *tag , *entity , m_useEffFormat , m_format1 , m_format2 )
<< endmsg ;
}
}
tmpCont.clear();
}
if ( m_statCoutFlag ) { std::cout << stars << std::endl; }
else { log << m_statPrintLevel << stars << endmsg; }
}

void ChronoStatSvc::saveStats | ( |  | ) |
| private

dump the statistics into an ASCII file for offline processing

CONTINUE

CONTINUE

Definition at line 532 of file ChronoStatSvc.cpp.

{
std::ofstream out( m_statsOutFileName.value().c_str(),
std::ios_base::out | std::ios_base::trunc );
if ( !out.good() ) {
MsgStream msg( msgSvc() , name() );
msg << MSG::INFO
<< "Could not open the output file for writing chrono statistics ["
<< m_statsOutFileName.value() << "]"
<< endmsg;
return;
} else {
// format it our way
out << std::scientific << std::setprecision(8) ;
}
// ChronoEntity
typedef std::pair<ChronoEntity*, const ChronoTag*> MPair;
typedef std::vector<MPair> MCont;
MCont chronos;
for( ChronoMap::iterator it = m_chronoEntities.begin() ;
m_chronoEntities.end() != it ; ++it ) {
chronos.push_back( MPair( &(it->second) , &(it->first) ) ) ;
}
// sort it
std::sort( chronos.begin() ,
chronos.end() ,
ComparePairOfChronoEntityAndChronoTag() );
// print User Time statistics
for( MCont::iterator iter = chronos.begin() ;
chronos.end() != iter;
++iter ) {
//
const ChronoEntity* entity = iter->first;
if( 0 == entity ) { continue ; }
const ChronoTag* tag = iter->second ;
if( 0 == tag ) { continue ; }
// create an entry in the .INI-like table
out << "\n[" << *tag << "]\n";
// user
out << "cpu_user_total = " << entity->uTotalTime() << "\n";
out << "cpu_user_min = " << entity->uMinimalTime() << "\n";
out << "cpu_user_mean = " << entity->uMeanTime() << "\n";
out << "cpu_user_RMS = " << entity->uRMSTime() << "\n";
out << "cpu_user_max = " << entity->uMaximalTime() << "\n";
out << "cpu_user_nbr = " << entity->nOfMeasurements() << "\n";
// system
out << "\n"; // just for clarity
out << "cpu_system_total = " << entity->kTotalTime() << "\n";
out << "cpu_system_min = " << entity->kMinimalTime() << "\n";
out << "cpu_system_mean = " << entity->kMeanTime() << "\n";
out << "cpu_system_RMS = " << entity->kRMSTime() << "\n";
out << "cpu_system_max = " << entity->kMaximalTime() << "\n";
out << "cpu_system_nbr = " << entity->nOfMeasurements() << "\n";
// real
out << "\n"; // just for clarity
out << "cpu_real_total = " << entity->eTotalTime() << "\n";
out << "cpu_real_min = " << entity->eMinimalTime() << "\n";
out << "cpu_real_mean = " << entity->eMeanTime() << "\n";
out << "cpu_real_RMS = " << entity->eRMSTime() << "\n";
out << "cpu_real_max = " << entity->eMaximalTime() << "\n";
out << "cpu_real_nbr = " << entity->nOfMeasurements() << "\n";
}
out << std::endl;
}

void ChronoStatSvc::stat | ( | const IChronoStatSvc::StatTag & | statTag,
|  | const IChronoStatSvc::StatFlag & | statFlag
| ) |  |
| virtual

Implementation of IChronoStatSvc::stat add statistical information to the entity , tagged by its name.

See Also
  IChronoStatSvc

Definition at line 471 of file ChronoStatSvc.cpp.

{
StatMap::iterator theIter=m_statEntities.find(statTag);
StatEntity * theStat=0 ;
// if new entity, specify the number of events to be skipped
if (theIter==m_statEntities.end()){
// new stat entity
StatEntity& theSe = m_statEntities[ statTag ];
theStat=& theSe;
theStat->setnEntriesBeforeReset(m_numberOfSkippedEventsForMemStat);
}
else
{
//existing stat entity
theStat=&((*theIter).second);
}
theStat->addFlag ( statFlag ) ;
}

const StatEntity * ChronoStatSvc::stat | ( | const IChronoStatSvc::StatTag & | t | ) | const
| virtual

extract the stat entity for the given tag (name)

See Also
  IChronoStatSvc

Parameters

  t | stat tag(name)

Returns
  pointer to stat entity

Definition at line 523 of file ChronoStatSvc.cpp.

{
StatMap::const_iterator it = m_statEntities.find ( t ) ;
if ( m_statEntities.end() != it ) { return &(it->second) ; }
return 0 ;
}

void ChronoStatSvc::statPrint | ( | const IChronoStatSvc::ChronoTag & | statTag | ) |
| virtual

prints (using message service) info about statistical entity, tagged by its name

See Also
  IChronoStatSvc

Definition at line 496 of file ChronoStatSvc.cpp.

{
MsgStream log ( msgSvc() , statTag ) ;
log << (MSG::Level) m_statPrintLevel << m_statEntities[ statTag ] << endmsg;
}

## Member Data Documentation

bool ChronoStatSvc::m_chronoCoutFlag
| private

flag for destination of the the final table

Definition at line 152 of file ChronoStatSvc.h.

ChronoMap ChronoStatSvc::m_chronoEntities
| private

chrono part

Definition at line 145 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_chronoOrderFlag
| private

flag for formattion the final statistic table

Definition at line 154 of file ChronoStatSvc.h.

MSG::Level ChronoStatSvc::m_chronoPrintLevel
| private

Definition at line 148 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_chronoTableFlag
| private

flag for printing the final table

Definition at line 150 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_format1
| private

format for regular statistical printout rows

Definition at line 185 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_format2
| private

format for "efficiency" statistical printout rows

Definition at line 187 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_header
| private

the header row

Definition at line 183 of file ChronoStatSvc.h.

int ChronoStatSvc::m_intChronoPrintLevel
| private

level of info printing

Definition at line 147 of file ChronoStatSvc.h.

int ChronoStatSvc::m_intStatPrintLevel
| private

level of info printing

Definition at line 169 of file ChronoStatSvc.h.

long ChronoStatSvc::m_numberOfSkippedEventsForMemStat
| private

Definition at line 163 of file ChronoStatSvc.h.

std::ofstream ChronoStatSvc::m_ofd
| private

Definition at line 194 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_perEventFile
| private

Definition at line 193 of file ChronoStatSvc.h.

TimeMap ChronoStatSvc::m_perEvtTime
| private

Definition at line 192 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printEllapsedTime
| private

flag for printing Ellapsed quantities

Definition at line 160 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printSystemTime
| private

flag for printing System quantities

Definition at line 158 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printUserTime
| private

flag for printing User quantities

Definition at line 156 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statCoutFlag
| private

flag for destination of the t he final table

Definition at line 174 of file ChronoStatSvc.h.

StatMap ChronoStatSvc::m_statEntities
| private

stat part

Definition at line 166 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statOrderFlag
| private

flag for formattion the final statistic table

Definition at line 176 of file ChronoStatSvc.h.

MSG::Level ChronoStatSvc::m_statPrintLevel
| private

Definition at line 170 of file ChronoStatSvc.h.

StringProperty ChronoStatSvc::m_statsOutFileName
| private

Name of the output file where we'll dump the stats.

Definition at line 180 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statTableFlag
| private

flag for printing the final table

Definition at line 172 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_useEffFormat
| private

flag to use the special "efficiency" format

Definition at line 189 of file ChronoStatSvc.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCommonSvc/src/ChronoStatSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCommonSvc/src/ChronoStatSvc.cpp