| The Gaudi Framework v32r1 (f65d50dc)

Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static 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 <src/ChronoStatSvc.h>`

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

## Public Types
typedef std::map< IChronoStatSvc::ChronoTag, ChronoEntity > | ChronoMap
| some useful typedefs More...
typedef std::map< IChronoStatSvc::StatTag, StatEntity > | StatMap
Public Types inherited from extends< Service, IChronoStatSvc, IIncidentListener >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from Service
using | Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...

## Public Member Functions
StatusCode | initialize () override
| Implementation of IService::initialize() More...
StatusCode | finalize () override
| Implementation of IService::finalize() More...
ChronoEntity * | chronoStart (const IChronoStatSvc::ChronoTag &chronoTag) override
| Implementation of IChronoStatSvc::chronoStart. More...
const ChronoEntity * | chronoStop (const IChronoStatSvc::ChronoTag &chronoTag) override
| Implementation of IChronoStatSvc::chronoStop. More...
IChronoStatSvc::ChronoTime | chronoDelta (const IChronoStatSvc::ChronoTag &chronoTag, IChronoStatSvc::ChronoType theType) override
| Implementation of IchronoStatSvc::chronoDelta. More...
void | chronoPrint (const IChronoStatSvc::ChronoTag &chronoTag) override
| Implementation of IChronoStatSvc::chronoPrint. More...
ChronoStatus | chronoStatus (const IChronoStatSvc::ChronoTag &chronoTag) override
| Implementation of IChronoStatSvc::chronoStatus. More...
void | stat (const IChronoStatSvc::StatTag &statTag, const IChronoStatSvc::StatFlag &statFlag) override
| Implementation of IChronoStatSvc::stat add statistical information to the entity , tagged by its name. More...
void | statPrint (const IChronoStatSvc::ChronoTag &statTag) override
| prints (using message service) info about statistical entity, tagged by its name More...
const ChronoEntity * | chrono (const IChronoStatSvc::ChronoTag &t) const override
| extract the chrono entity for the given tag (name) More...
StatEntity * | stat (const IChronoStatSvc::StatTag &t) override
| extract the stat entity for the given tag (name) More...
| ChronoStatSvc (const std::string &name, ISvcLocator *svcloc)
| Default constructor. More...
void | merge (const ChronoStatSvc &css)
| Compound assignment operator. More...
void | handle (const Incident &incident) override
Public Member Functions inherited from extends< Service, IChronoStatSvc, IIncidentListener >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
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. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, 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. More...
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | msgLevel () const
| get the cached level (originally extracted from the embedded MsgStream) More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const
| Backward compatibility function for getting the output level. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...

## Protected Member Functions
void | printStats ()
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level | setUpMessaging () const
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

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

## Private Member Functions
| ChronoStatSvc ()=delete
| ChronoStatSvc (const ChronoStatSvc &)=delete
ChronoStatSvc & | operator= (const ChronoStatSvc &)=delete
void | saveStats ()
| dump the statistics into an ASCII file for offline processing More...
bool | isMT () const
ChronoEntity & | getEntity (const ChronoTag &chronoTag)

## Static Private Member Functions
static MSG::Level | int2level (int l)

## Private Attributes
ChronoMap | m_chronoEntities
| chrono part More...
std::mutex | m_mutex
| Mutex protecting m_chronoEntities. More...
MSG::Level | m_chronoPrintLevel = MSG::INFO
| level of info printing More...
StatMap | m_statEntities
| stat part More...
MSG::Level | m_statPrintLevel = MSG::INFO
| level of info printing More...
Gaudi::Property< bool > | m_chronoTableFlag
Gaudi::Property< bool > | m_chronoCoutFlag
Gaudi::Property< int > | m_intChronoPrintLevel
Gaudi::Property< bool > | m_chronoOrderFlag {this, "ChronoTableToBeOrdered", true, "should the printout be ordered"}
Gaudi::Property< bool > | m_printUserTime {this, "PrintUserTime", true}
Gaudi::Property< bool > | m_printSystemTime {this, "PrintSystemTime", false}
Gaudi::Property< bool > | m_printEllapsedTime {this, "PrintEllapsedTime", false}
Gaudi::Property< bool > | m_statTableFlag
Gaudi::Property< bool > | m_statCoutFlag
Gaudi::Property< int > | m_intStatPrintLevel
Gaudi::Property< bool > | m_statOrderFlag {this, "StatTableToBeOrdered", true, "should the printout be ordered"}
Gaudi::Property< std::string > | m_statsOutFileName
Gaudi::Property< std::string > | m_header
Gaudi::Property< bool > | m_useEffFormat
Gaudi::Property< std::string > | m_perEventFile {this, "PerEventFile", "", "File name for per-event deltas"}
ServiceHandle< IInterface > | m_hiveWhiteBoardSvc {this, "HiveWhiteBoardSvc", "EventDataSvc"}
TimeMap | m_perEvtTime
std::ofstream | m_ofd

## Additional Inherited Members
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, " unused"}
Gaudi::Property< bool > | m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
Gaudi::Property< bool > | m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
Gaudi::Property< bool > | m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
Gaudi::Property< bool > | m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
Gaudi::Property< bool > | m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
Gaudi::Property< bool > | m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## 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 @daate: December 1, 1999

Definition at line 37 of file ChronoStatSvc.h.

## Member Typedef Documentation

## ◆ ChronoMap

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

some useful typedefs

Definition at line 41 of file ChronoStatSvc.h.

## ◆ lock_t

typedef std::lock_guard<std::mutex> ChronoStatSvc::lock_t
| private

Definition at line 151 of file ChronoStatSvc.h.

## ◆ StatMap

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

Definition at line 42 of file ChronoStatSvc.h.

## ◆ TimeMap

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

Definition at line 196 of file ChronoStatSvc.h.

## Constructor & Destructor Documentation

## ◆ ChronoStatSvc() [1/3]

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

Default constructor.

Parameters

  name | service instance name
  svcloc | pointer to service locator

Definition at line 109 of file ChronoStatSvc.h.

109 : base_class( name, svcloc ) {}
extends< Service, IChronoStatSvc, IIncidentListener >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274

## ◆ ChronoStatSvc() [2/3]

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

## ◆ ChronoStatSvc() [3/3]

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

## Member Function Documentation

## ◆ chrono()

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

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 342 of file ChronoStatSvc.cpp.

342 {
343 lock_t lock( m_mutex );
344 auto it = m_chronoEntities.find( t );
345 return m_chronoEntities.end() != it ? &( it->second ) : nullptr;
346 }
ChronoStatSvc::m_mutex
std::mutex m_mutex
Mutex protecting m_chronoEntities.
Definition: ChronoStatSvc.h:150
std::map::end
T end(T... args)
std::lock
T lock(T... args)
std::map::find
T find(T... args)
ChronoStatSvc::lock_t
std::lock_guard< std::mutex > lock_t
Definition: ChronoStatSvc.h:151
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:145

## ◆ chronoDelta()

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

Implementation of IchronoStatSvc::chronoDelta.

See also
  IChronoStatSvc

Definition at line 291 of file ChronoStatSvc.cpp.

292 {
293 return getEntity( chronoTag ).delta( theType );
294 }
ChronoStatSvc::getEntity
ChronoEntity & getEntity(const ChronoTag &chronoTag)
Definition: ChronoStatSvc.h:136
ChronoEntity::delta
IChronoSvc::ChronoTime delta(IChronoSvc::ChronoType type) const
return the last delta-time of type "type"
Definition: ChronoEntity.h:261

## ◆ chronoPrint()

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

Implementation of IChronoStatSvc::chronoPrint.

See also
  IChronoStatSvc

Definition at line 298 of file ChronoStatSvc.cpp.

298 {
299 MsgStream log( msgSvc(), chronoTag );
300 if ( m_printUserTime ) { log << m_chronoPrintLevel << getEntity( chronoTag ).outputUserTime() << endmsg; }
301 if ( m_printSystemTime ) { log << m_chronoPrintLevel << getEntity( chronoTag ).outputSystemTime() << endmsg; }
302 }
ChronoStatSvc::getEntity
ChronoEntity & getEntity(const ChronoTag &chronoTag)
Definition: ChronoStatSvc.h:136
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
ChronoStatSvc::m_printUserTime
Gaudi::Property< bool > m_printUserTime
Definition: ChronoStatSvc.h:169
ChronoStatSvc::m_chronoPrintLevel
MSG::Level m_chronoPrintLevel
level of info printing
Definition: ChronoStatSvc.h:154
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
ChronoEntity::outputUserTime
std::string outputUserTime() const
print the chrono ;
Definition: ChronoEntity.cpp:82
ChronoEntity::outputSystemTime
std::string outputSystemTime() const
print the chrono ;
Definition: ChronoEntity.cpp:89
Gaudi.Configuration.log
log
Definition: Configuration.py:13
ChronoStatSvc::m_printSystemTime
Gaudi::Property< bool > m_printSystemTime
Definition: ChronoStatSvc.h:170

## ◆ chronoStart()

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

Implementation of IChronoStatSvc::chronoStart.

See also
  IChronoStatSvc

Definition at line 275 of file ChronoStatSvc.cpp.

275 {
276 ChronoEntity& entity = getEntity( chronoTag );
277 entity.start();
278 return &entity;
279 }
ChronoStatSvc::getEntity
ChronoEntity & getEntity(const ChronoTag &chronoTag)
Definition: ChronoStatSvc.h:136
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
ChronoEntity::start
IChronoSvc::ChronoStatus start()
start the current chrono
Definition: ChronoEntity.cpp:46

## ◆ chronoStatus()

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

Implementation of IChronoStatSvc::chronoStatus.

See also
  IChronoStatSvc

Definition at line 306 of file ChronoStatSvc.cpp.

306 {
307 return getEntity( chronoTag ).status();
308 }
ChronoStatSvc::getEntity
ChronoEntity & getEntity(const ChronoTag &chronoTag)
Definition: ChronoStatSvc.h:136
ChronoEntity::status
IChronoSvc::ChronoStatus status() const
return the status of chrono
Definition: ChronoEntity.h:177

## ◆ chronoStop()

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

Implementation of IChronoStatSvc::chronoStop.

See also
  IChronoStatSvc

Definition at line 283 of file ChronoStatSvc.cpp.

283 {
284 ChronoEntity& entity = getEntity( chronoTag );
285 entity.stop();
286 return &entity;
287 }
ChronoStatSvc::getEntity
ChronoEntity & getEntity(const ChronoTag &chronoTag)
Definition: ChronoStatSvc.h:136
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
ChronoEntity::stop
IChronoSvc::ChronoStatus stop()
stop the chrono
Definition: ChronoEntity.cpp:61

## ◆ finalize()

StatusCode ChronoStatSvc::finalize | ( |  | ) |
| override

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

Definition at line 126 of file ChronoStatSvc.cpp.

126 {
127 std::string local = name() + ".finalize()";
129 MsgStream main_log( msgSvc(), local );
132 chronoStop( name() );
133
134 if ( m_ofd.is_open() ) {
135 debug() << "writing per-event timing data to '" << m_perEventFile << "'" << endmsg;
136 for ( const auto& itr : m_perEvtTime ) {
137 m_ofd << itr.first.substr( 0, itr.first.length() - 8 ) << " ";
138 for ( const auto& itt : itr.second ) { m_ofd << " " << (long int)( itt ); }
139 m_ofd << std::endl;
140 }
141
142 m_ofd.close();
143 }
144
147 if ( m_chronoTableFlag && !m_chronoEntities.empty() && ( m_printUserTime || m_printSystemTime ) ) {
149 MsgStream log( msgSvc(), "*****Chrono*****" );
150 const std::string stars( ( m_chronoCoutFlag ) ? 126 : 100, '*' );
151 if ( m_chronoCoutFlag ) {
152 std::cout << stars << std::endl;
153 if ( isMT() ) { std::cout << "WARNING: MT job; statistics are unreliable" << std::endl; }
154 std::cout << local << " The Final CPU consumption (Chrono) Table "
155 << ( m_chronoOrderFlag ? "(ordered)" : "(not ordered)" ) << std::endl;
156 std::cout << stars << std::endl;
157 } else {
158 log << m_chronoPrintLevel << stars << endmsg;
159 if ( isMT() ) { log << m_chronoPrintLevel << "WARNING: MT job; statistics are unreliable" << endmsg; }
160 log << m_chronoPrintLevel << " The Final CPU consumption ( Chrono ) Table "
161 << ( m_chronoOrderFlag ? "(ordered)" : "(not ordered)" ) << endmsg;
162 log << m_chronoPrintLevel << stars << endmsg;
163 }
165 { // prepare container for printing
166 std::vector<std::pair<ChronoEntity*, const ChronoTag*>> tmpCont;
167 tmpCont.reserve( m_chronoEntities.size() );
168 for ( auto& it : m_chronoEntities ) { tmpCont.emplace_back( &it.second, &it.first ); }
169 // sort it
170 if ( m_chronoOrderFlag ) std::sort( tmpCont.begin(), tmpCont.end(), CompareFirstOfPointerPair );
171 // print User Time statistics
172 if ( m_printUserTime ) {
173 for ( auto iter = tmpCont.begin(); tmpCont.end() != iter; ++iter ) {
174 //
175 ChronoEntity* entity = iter->first;
176 if ( !entity ) { continue; }
177 const ChronoTag* tag = iter->second;
178 if ( !tag ) { continue; }
179 entity->stop();
181 if ( m_chronoCoutFlag )
183 {
184 std::cout << *tag << "\t" << entity->outputUserTime() << std::endl;
185 } else
186 {
187 MsgStream( msgSvc(), *tag ) << m_chronoPrintLevel << entity->outputUserTime() << endmsg;
188 }
189 //
190 }
191 }
193 if ( m_printSystemTime ) {
196 if ( m_printUserTime && m_chronoCoutFlag ) {
197 std::cout << stars << std::endl;
198 } else if ( m_printUserTime && !m_chronoCoutFlag ) {
199 log << m_chronoPrintLevel << stars << endmsg;
200 }
202 for ( auto iter = tmpCont.begin(); tmpCont.end() != iter; ++iter ) {
204 ChronoEntity* entity = iter->first;
205 if ( !entity ) { continue; }
206 const ChronoTag* tag = iter->second;
207 if ( !tag ) { continue; }
208 entity->stop();
210 if ( m_chronoCoutFlag )
212 {
213 std::cout << *tag << "\t" << entity->outputSystemTime() << std::endl;
214 } else
215 {
216 MsgStream( msgSvc(), *tag ) << m_chronoPrintLevel << entity->outputSystemTime() << endmsg;
217 }
218 //
219 }
220 }
222 if ( m_printEllapsedTime ) {
225 if ( ( m_printUserTime || m_printSystemTime ) && m_chronoCoutFlag ) {
226 std::cout << stars << std::endl;
227 } else if ( ( m_printUserTime || m_printSystemTime ) && !m_chronoCoutFlag ) {
228 log << m_chronoPrintLevel << stars << endmsg;
229 }
231 for ( const auto& i : tmpCont ) {
233 ChronoEntity* entity = i.first;
234 if ( !entity ) { continue; }
235 const ChronoTag* tag = i.second;
236 if ( !tag ) { continue; }
237 entity->stop();
239 if ( m_chronoCoutFlag )
241 {
242 std::cout << *tag << "\t" << entity->outputElapsedTime() << std::endl;
243 } else
244 {
245 MsgStream( msgSvc(), *tag ) << m_chronoPrintLevel << entity->outputElapsedTime() << endmsg;
246 }
247 //
248 }
249 }
251 tmpCont.clear();
252 }
254 if ( m_chronoCoutFlag ) {
255 std::cout << stars << std::endl;
256 } else {
257 log << m_chronoPrintLevel << stars << endmsg;
258 }
259 }
260
262
264 if ( m_statTableFlag ) { printStats(); }
265
266 if ( !m_statsOutFileName.value().empty() ) { saveStats(); }
267
268 main_log << MSG::INFO << " Service finalized successfully " << endmsg;
269
270 return Service::finalize();
271 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::map::empty
T empty(T... args)
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:164
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
std::endl
T endl(T... args)
ChronoStatSvc::m_chronoOrderFlag
Gaudi::Property< bool > m_chronoOrderFlag
Definition: ChronoStatSvc.h:168
ChronoStatSvc::m_printUserTime
Gaudi::Property< bool > m_printUserTime
Definition: ChronoStatSvc.h:169
std::vector::end
T end(T... args)
std::string
STL class.
ChronoStatSvc::printStats
void printStats()
Definition: ChronoStatSvc.cpp:442
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
ChronoStatSvc::saveStats
void saveStats()
dump the statistics into an ASCII file for offline processing
Definition: ChronoStatSvc.cpp:361
CompareFirstOfPointerPair
constexpr struct CompareFirstOfPointerPair_t CompareFirstOfPointerPair
MsgStream::clear
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:171
ChronoStatSvc::m_perEvtTime
TimeMap m_perEvtTime
Definition: ChronoStatSvc.h:197
std::ofstream::close
T close(T... args)
ChronoStatSvc::chronoStop
const ChronoEntity * chronoStop(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStop.
Definition: ChronoStatSvc.cpp:283
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
ChronoStatSvc::m_chronoTableFlag
Gaudi::Property< bool > m_chronoTableFlag
Definition: ChronoStatSvc.h:161
ChronoStatSvc::m_ofd
std::ofstream m_ofd
Definition: ChronoStatSvc.h:198
ChronoStatSvc::m_chronoPrintLevel
MSG::Level m_chronoPrintLevel
level of info printing
Definition: ChronoStatSvc.h:154
ChronoStatSvc::m_printEllapsedTime
Gaudi::Property< bool > m_printEllapsedTime
Definition: ChronoStatSvc.h:171
std::map::size
T size(T... args)
std::vector
STL class.
std::vector::begin
T begin(T... args)
ChronoStatSvc::m_statTableFlag
Gaudi::Property< bool > m_statTableFlag
Definition: ChronoStatSvc.h:172
ChronoStatSvc::isMT
bool isMT() const
Definition: ChronoStatSvc.cpp:428
ChronoStatSvc::m_statsOutFileName
Gaudi::Property< std::string > m_statsOutFileName
Definition: ChronoStatSvc.h:181
ChronoStatSvc::m_chronoCoutFlag
Gaudi::Property< bool > m_chronoCoutFlag
Definition: ChronoStatSvc.h:163
std::sort
T sort(T... args)
std::ofstream::is_open
T is_open(T... args)
MSG::INFO
Definition: IMessageSvc.h:15
ChronoEntity::stop
IChronoSvc::ChronoStatus stop()
stop the chrono
Definition: ChronoEntity.cpp:61
std::cout
ChronoEntity::outputElapsedTime
std::string outputElapsedTime() const
print the chrono ;
Definition: ChronoEntity.cpp:95
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
ChronoEntity::outputUserTime
std::string outputUserTime() const
print the chrono ;
Definition: ChronoEntity.cpp:82
ChronoEntity::outputSystemTime
std::string outputSystemTime() const
print the chrono ;
Definition: ChronoEntity.cpp:89
std::vector::reserve
T reserve(T... args)
Gaudi.Configuration.log
log
Definition: Configuration.py:13
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:145
std::vector::emplace_back
T emplace_back(T... args)
ChronoStatSvc::m_printSystemTime
Gaudi::Property< bool > m_printSystemTime
Definition: ChronoStatSvc.h:170
ChronoStatSvc::m_perEventFile
Gaudi::Property< std::string > m_perEventFile
Definition: ChronoStatSvc.h:192

## ◆ getEntity()

ChronoEntity& ChronoStatSvc::getEntity | ( | const ChronoTag & | chronoTag | ) |
| inline private

Definition at line 136 of file ChronoStatSvc.h.

136 {
137 lock_t lock( m_mutex );
138 return m_chronoEntities[chronoTag];
139 }
ChronoStatSvc::m_mutex
std::mutex m_mutex
Mutex protecting m_chronoEntities.
Definition: ChronoStatSvc.h:150
std::lock
T lock(T... args)
ChronoStatSvc::lock_t
std::lock_guard< std::mutex > lock_t
Definition: ChronoStatSvc.h:151
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:145

## ◆ handle()

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

Definition at line 507 of file ChronoStatSvc.cpp.

507 {
508
509 if ( !m_ofd.is_open() ) return;
510
511 lock_t lock( m_mutex );
512 for ( const auto& itr : m_chronoEntities ) {
513 if ( itr.first.find( ":Execute" ) == std::string::npos ) continue;
514
515 auto itm = m_perEvtTime.find( itr.first );
516 if ( itm == m_perEvtTime.end() ) {
517 m_perEvtTime[itr.first] = {itr.second.delta( IChronoSvc::ELAPSED )};
518 } else {
519 itm->second.push_back( itr.second.delta( IChronoSvc::ELAPSED ) );
520 }
521 }
522 }
ChronoStatSvc::m_mutex
std::mutex m_mutex
Mutex protecting m_chronoEntities.
Definition: ChronoStatSvc.h:150
std::map::end
T end(T... args)
ChronoStatSvc::m_perEvtTime
TimeMap m_perEvtTime
Definition: ChronoStatSvc.h:197
std::lock
T lock(T... args)
ChronoStatSvc::m_ofd
std::ofstream m_ofd
Definition: ChronoStatSvc.h:198
IChronoSvc::ELAPSED
Definition: IChronoSvc.h:46
std::map::find
T find(T... args)
ChronoStatSvc::lock_t
std::lock_guard< std::mutex > lock_t
Definition: ChronoStatSvc.h:151
std::ofstream::is_open
T is_open(T... args)
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:145

## ◆ initialize()

StatusCode ChronoStatSvc::initialize | ( |  | ) |
| override

Implementation of IService::initialize()

start its own chrono

Definition at line 86 of file ChronoStatSvc.cpp.

86 {
87 StatusCode sc = Service::initialize();
88 if ( sc.isFailure() ) return sc;
90 // Set my own properties
91 sc = setProperties();
92
93 if ( sc.isFailure() ) {
94 error() << "setting my properties" << endmsg;
95 return StatusCode::FAILURE;
96 }
97
98 // only add an EndEvent listener if per-event output requested
99 if ( !m_perEventFile.empty() ) {
100 m_ofd.open( m_perEventFile );
101 if ( !m_ofd.is_open() ) {
102 error() << "unable to open per-event output file \"" << m_perEventFile << "\"" << endmsg;
103 return StatusCode::FAILURE;
104 } else {
105 auto ii = serviceLocator()->service<IIncidentSvc>( "IncidentSvc" );
106 if ( !ii ) {
107 error() << "Unable to find IncidentSvc" << endmsg;
108 return StatusCode::FAILURE;
109 }
110 ii->addListener( this, IncidentType::EndEvent );
111 }
112 }
113
114 if ( m_chronoTableFlag && !m_printUserTime && !m_printSystemTime && !m_printEllapsedTime ) { m_printUserTime = true; }
116 if ( m_printUserTime || m_printSystemTime || m_printEllapsedTime ) { m_chronoTableFlag = true; }
119 chronoStart( name() );
121 return StatusCode::SUCCESS;
122 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:60
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:277
std::ofstream::open
T open(T... args)
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
ChronoStatSvc::m_printUserTime
Gaudi::Property< bool > m_printUserTime
Definition: ChronoStatSvc.h:169
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:76
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
ChronoStatSvc::m_chronoTableFlag
Gaudi::Property< bool > m_chronoTableFlag
Definition: ChronoStatSvc.h:161
ChronoStatSvc::m_ofd
std::ofstream m_ofd
Definition: ChronoStatSvc.h:198
Service::setProperties
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:280
ChronoStatSvc::m_printEllapsedTime
Gaudi::Property< bool > m_printEllapsedTime
Definition: ChronoStatSvc.h:171
ChronoStatSvc::chronoStart
ChronoEntity * chronoStart(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStart.
Definition: ChronoStatSvc.cpp:275
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130
std::ofstream::is_open
T is_open(T... args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
ChronoStatSvc::m_printSystemTime
Gaudi::Property< bool > m_printSystemTime
Definition: ChronoStatSvc.h:170
ChronoStatSvc::m_perEventFile
Gaudi::Property< std::string > m_perEventFile
Definition: ChronoStatSvc.h:192

## ◆ int2level()

static MSG::Level ChronoStatSvc::int2level | ( | int | l | ) |
| inline static private

Definition at line 142 of file ChronoStatSvc.h.

142 {
143 return static_cast<MSG::Level>(
144 std::max( std::min( l, static_cast<int>( MSG::FATAL ) ), static_cast<int>( MSG::NIL ) ) );
145 };
std::min
T min(T... args)
MSG::FATAL
Definition: IMessageSvc.h:15
MSG::NIL
Definition: IMessageSvc.h:15
std::max
T max(T... args)
gaudirun.l
dictionary l
Definition: gaudirun.py:521

## ◆ isMT()

bool ChronoStatSvc::isMT | ( |  | ) | const
| private

Definition at line 428 of file ChronoStatSvc.cpp.

428 {
429 bool isMT = false;
430 if ( m_hiveWhiteBoardSvc.retrieve().isFailure() ) {
431 error() << "Cannot retrieve HiveWhiteBoardSvc";
432 } else {
433 // In non-MT mode, `EventDataSvc' does not have an IHiveWhiteBoard interface.
434 const SmartIF<IHiveWhiteBoard> wb( m_hiveWhiteBoardSvc.get() );
435 if ( wb && wb->getNumberOfStores() > 1 ) { isMT = true; }
436 }
437 return isMT;
438 }
SmartIF< IHiveWhiteBoard >
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
ServiceHandle::retrieve
StatusCode retrieve() const
Retrieve the Service.
Definition: ServiceHandle.h:70
ChronoStatSvc::m_hiveWhiteBoardSvc
ServiceHandle< IInterface > m_hiveWhiteBoardSvc
Definition: ChronoStatSvc.h:194
ServiceHandle::get
T * get() const
Release the Service.
Definition: ServiceHandle.h:81
ChronoStatSvc::isMT
bool isMT() const
Definition: ChronoStatSvc.cpp:428
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:130

## ◆ merge()

void ChronoStatSvc::merge | ( | const ChronoStatSvc & | css | ) |

Compound assignment operator.

Definition at line 56 of file ChronoStatSvc.cpp.

56 {
57
58 // Add the content of the maps, leave the rest unchanged
59
60 lock_t lock( m_mutex );
61 lock_t otherLock( css.m_mutex );
62
63 // Merge Chronomaps
64 for ( auto& item : css.m_chronoEntities ) {
65 const IChronoStatSvc::ChronoTag& key = item.first;
66 const ChronoEntity& val = item.second;
67 if ( m_chronoEntities.count( key ) )
68 m_chronoEntities[key] += val;
69 else
70 m_chronoEntities.insert( std::pair<IChronoStatSvc::ChronoTag, ChronoEntity>( key, val ) );
71 }
72
73 // Merge StatMaps
74 for ( auto& item : css.m_statEntities ) {
75 const IChronoStatSvc::StatTag& key = item.first;
76 const StatEntity& val = item.second;
77 if ( m_statEntities.count( key ) )
78 m_statEntities[key] += val;
79 else
80 m_statEntities.emplace( key, val );
81 }
82 }
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:157
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
ChronoStatSvc::m_mutex
std::mutex m_mutex
Mutex protecting m_chronoEntities.
Definition: ChronoStatSvc.h:150
std::lock
T lock(T... args)
std::map::count
T count(T... args)
std::pair
std::map::insert
T insert(T... args)
ChronoStatSvc::lock_t
std::lock_guard< std::mutex > lock_t
Definition: ChronoStatSvc.h:151
std::map::emplace
T emplace(T... args)
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:145

## ◆ operator=()

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

## ◆ printStats()

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

nothing to print?

CONTINUE

CONTINUE

decoration

Definition at line 442 of file ChronoStatSvc.cpp.

442 {
444 if ( m_statEntities.empty() ) { return; }
445
446 MsgStream log( msgSvc(), "******Stat******" );
448 const std::string stars( ( m_statCoutFlag ) ? 126 : 100, '*' );
450 if ( m_statCoutFlag ) {
451 std::cout << stars << std::endl;
452 if ( isMT() ) { std::cout << "WARNING: MT job; statistics are unreliable" << std::endl; }
453 std::cout << " The Final stat Table " << ( m_statOrderFlag ? "(ordered)" : "(not ordered)" ) << std::endl;
454 std::cout << stars << std::endl;
455 } else {
456 log << m_statPrintLevel << stars << endmsg;
457 if ( isMT() ) { log << (MSG::Level)m_chronoPrintLevel << "WARNING: MT job; statistics are unreliable" << endmsg; }
458 log << m_statPrintLevel << " The Final stat Table " << ( m_statOrderFlag ? "(ordered)" : "(not ordered)" )
459 << endmsg;
460 log << m_statPrintLevel << stars << endmsg;
461 }
462
463 {
464 // prepare container for printing
465 typedef std::pair<const StatEntity*, const StatTag*> SPair;
466 typedef std::vector<SPair> SCont;
467 SCont tmpCont;
468 std::transform( std::begin( m_statEntities ), std::end( m_statEntities ), std::back_inserter( tmpCont ),
469 []( StatMap::const_reference i ) { return std::make_pair( &i.second, &i.first ); } );
470 // sort it
471 if ( m_statOrderFlag ) std::sort( tmpCont.begin(), tmpCont.end(), CompareFirstOfPointerPair );
472 // print the table header
473 if ( m_statCoutFlag ) {
474 std::cout << m_header.value() << std::endl;
475 } else {
476 log << m_statPrintLevel << m_header.value() << endmsg;
477 }
478
479 // loop over counters and print them:
480 for ( const auto& iter : tmpCont ) {
482 const StatEntity* entity = iter.first;
483 if ( !entity ) { continue; }
484 const StatTag* tag = iter.second;
485 if ( !tag ) { continue; }
486 if ( m_statCoutFlag ) {
488 entity->print( std::cout, true, *tag, m_useEffFormat, "%|-15.15s|%|17t|" );
489 } else {
490 std::ostringstream ost;
491 entity->print( ost, true, *tag, m_useEffFormat, "%|-15.15s|%|17t|" );
492 log << m_statPrintLevel << ost.str() << endmsg;
493 }
494 }
495 tmpCont.clear();
496 }
498 if ( m_statCoutFlag ) {
499 std::cout << stars << std::endl;
500 } else {
501 log << m_statPrintLevel << stars << endmsg;
502 }
503 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::map::empty
T empty(T... args)
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
ChronoStatSvc::m_header
Gaudi::Property< std::string > m_header
Definition: ChronoStatSvc.h:185
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:157
ChronoStatSvc::m_statCoutFlag
Gaudi::Property< bool > m_statCoutFlag
Definition: ChronoStatSvc.h:174
std::endl
T endl(T... args)
std::end
T end(T... args)
std::string
STL class.
MSG::Level
Level
Definition: IMessageSvc.h:15
ChronoStatSvc::m_useEffFormat
Gaudi::Property< bool > m_useEffFormat
Definition: ChronoStatSvc.h:189
CompareFirstOfPointerPair
constexpr struct CompareFirstOfPointerPair_t CompareFirstOfPointerPair
MsgStream::clear
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:171
std::ostringstream
STL class.
ChronoStatSvc::m_statOrderFlag
Gaudi::Property< bool > m_statOrderFlag
Definition: ChronoStatSvc.h:179
std::ostringstream::str
T str(T... args)
std::make_pair
T make_pair(T... args)
ChronoStatSvc::m_chronoPrintLevel
MSG::Level m_chronoPrintLevel
level of info printing
Definition: ChronoStatSvc.h:154
std::pair
std::vector
STL class.
std::begin
T begin(T... args)
std::back_inserter
T back_inserter(T... args)
ChronoStatSvc::isMT
bool isMT() const
Definition: ChronoStatSvc.cpp:428
ChronoStatSvc::m_statPrintLevel
MSG::Level m_statPrintLevel
level of info printing
Definition: ChronoStatSvc.h:159
std::sort
T sort(T... args)
std::transform
T transform(T... args)
std::cout
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## ◆ saveStats()

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

dump the statistics into an ASCII file for offline processing

CONTINUE

CONTINUE

Definition at line 361 of file ChronoStatSvc.cpp.

361 {
362 std::ofstream out( m_statsOutFileName.value(), std::ios_base::out | std::ios_base::trunc );
363 if ( !out.good() ) {
364 info() << "Could not open the output file for writing chrono statistics [" << m_statsOutFileName.value() << "]"
365 << endmsg;
366 return;
367 } else {
368 // format it our way
369 out << std::scientific << std::setprecision( 8 );
370 }
371
372 // ChronoEntity
373 std::vector<std::pair<const ChronoEntity*, const ChronoTag*>> chronos;
374 {
375 lock_t lock( m_mutex );
376 chronos.reserve( m_chronoEntities.size() );
377 std::transform( std::begin( m_chronoEntities ), std::end( m_chronoEntities ), std::back_inserter( chronos ),
378 []( ChronoMap::const_reference i ) { return std::make_pair( &i.second, &i.first ); } );
379 }
380
381 // sort it
382 std::sort( std::begin( chronos ), std::end( chronos ), CompareFirstOfPointerPair );
383
384 // print User Time statistics
385 for ( const auto& iter : chronos ) {
386 //
387 const ChronoEntity* entity = iter.first;
388 if ( !entity ) { continue; }
389
390 const ChronoTag* tag = iter.second;
391 if ( !tag ) { continue; }
392
393 // create an entry in the .INI-like table
394 out << "\n[" << *tag << "]\n";
395
396 // user
397 out << "cpu_user_total = " << entity->uTotalTime() << "\n";
398 out << "cpu_user_min = " << entity->uMinimalTime() << "\n";
399 out << "cpu_user_mean = " << entity->uMeanTime() << "\n";
400 out << "cpu_user_RMS = " << entity->uRMSTime() << "\n";
401 out << "cpu_user_max = " << entity->uMaximalTime() << "\n";
402 out << "cpu_user_nbr = " << entity->nOfMeasurements() << "\n";
403
404 // system
405 out << "\n"; // just for clarity
406 out << "cpu_system_total = " << entity->kTotalTime() << "\n";
407 out << "cpu_system_min = " << entity->kMinimalTime() << "\n";
408 out << "cpu_system_mean = " << entity->kMeanTime() << "\n";
409 out << "cpu_system_RMS = " << entity->kRMSTime() << "\n";
410 out << "cpu_system_max = " << entity->kMaximalTime() << "\n";
411 out << "cpu_system_nbr = " << entity->nOfMeasurements() << "\n";
412
413 // real
414 out << "\n"; // just for clarity
415 out << "cpu_real_total = " << entity->eTotalTime() << "\n";
416 out << "cpu_real_min = " << entity->eMinimalTime() << "\n";
417 out << "cpu_real_mean = " << entity->eMeanTime() << "\n";
418 out << "cpu_real_RMS = " << entity->eRMSTime() << "\n";
419 out << "cpu_real_max = " << entity->eMaximalTime() << "\n";
420 out << "cpu_real_nbr = " << entity->nOfMeasurements() << "\n";
421 }
422
423 out << std::endl;
424 }
ChronoEntity::eRMSTime
double eRMSTime() const
r.m.s Elapsed Time
Definition: ChronoEntity.h:245
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
std::endl
T endl(T... args)
ChronoStatSvc::m_mutex
std::mutex m_mutex
Mutex protecting m_chronoEntities.
Definition: ChronoStatSvc.h:150
ChronoEntity::uMinimalTime
double uMinimalTime() const
minimal measurement for user time
Definition: ChronoEntity.h:185
std::end
T end(T... args)
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
ChronoEntity::kRMSTime
double kRMSTime() const
r.m.s Kernel Time
Definition: ChronoEntity.h:237
std::ofstream
STL class.
ChronoEntity::eMaximalTime
double eMaximalTime() const
maximal measurement for elapsed time
Definition: ChronoEntity.h:205
ChronoEntity::uTotalTime
double uTotalTime() const
total user time
Definition: ChronoEntity.h:209
CompareFirstOfPointerPair
constexpr struct CompareFirstOfPointerPair_t CompareFirstOfPointerPair
ChronoEntity::nOfMeasurements
unsigned long nOfMeasurements() const
number of chrono measurements
Definition: ChronoEntity.h:181
ChronoEntity::eMinimalTime
double eMinimalTime() const
minimal measurement for elapsed time
Definition: ChronoEntity.h:193
std::lock
T lock(T... args)
ChronoEntity::uMeanTime
double uMeanTime() const
average User Time
Definition: ChronoEntity.h:229
ChronoEntity::kMeanTime
double kMeanTime() const
average Kernel Time
Definition: ChronoEntity.h:225
std::make_pair
T make_pair(T... args)
ChronoEntity::eTotalTime
double eTotalTime() const
total Elapsed time
Definition: ChronoEntity.h:217
std::scientific
T scientific(T... args)
std::map::size
T size(T... args)
std::vector
STL class.
ChronoEntity::kTotalTime
double kTotalTime() const
total Kernel time
Definition: ChronoEntity.h:213
std::begin
T begin(T... args)
std::back_inserter
T back_inserter(T... args)
ChronoStatSvc::lock_t
std::lock_guard< std::mutex > lock_t
Definition: ChronoStatSvc.h:151
ChronoEntity::uMaximalTime
double uMaximalTime() const
maximal measurement for user time
Definition: ChronoEntity.h:197
ChronoEntity::kMinimalTime
double kMinimalTime() const
minimal measurement for kernel time
Definition: ChronoEntity.h:189
ChronoStatSvc::m_statsOutFileName
Gaudi::Property< std::string > m_statsOutFileName
Definition: ChronoStatSvc.h:181
std::sort
T sort(T... args)
std::transform
T transform(T... args)
ChronoEntity::eMeanTime
double eMeanTime() const
average Elapsed Time
Definition: ChronoEntity.h:233
std::setprecision
T setprecision(T... args)
ChronoEntity::kMaximalTime
double kMaximalTime() const
maximal measurement for kernel time
Definition: ChronoEntity.h:201
ChronoEntity::uRMSTime
double uRMSTime() const
r.m.s User Time
Definition: ChronoEntity.h:241
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
std::vector::reserve
T reserve(T... args)
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:145

## ◆ stat() [1/2]

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

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

See also
  IChronoStatSvc

Definition at line 312 of file ChronoStatSvc.cpp.

312 {
313 auto theIter = m_statEntities.find( statTag );
314
315 StatEntity* theStat = nullptr;
316 // if new entity, specify the number of events to be skipped
317 if ( theIter == m_statEntities.end() ) {
318 // new stat entity
319 StatEntity& theSe = m_statEntities[statTag];
320 theStat = &theSe;
321 } else {
322 // existing stat entity
323 theStat = &theIter->second;
324 }
325
326 theStat->addFlag( statFlag );
327 }
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:157
std::map::end
T end(T... args)
std::map::find
T find(T... args)

## ◆ stat() [2/2]

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

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 354 of file ChronoStatSvc.cpp.

354 {
355 auto it = m_statEntities.find( t );
356 return m_statEntities.end() != it ? &( it->second ) : nullptr;
357 }
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:157
std::map::end
T end(T... args)
std::map::find
T find(T... args)

## ◆ statPrint()

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

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

See also
  IChronoStatSvc

Definition at line 331 of file ChronoStatSvc.cpp.

331 {
332 MsgStream log( msgSvc(), statTag );
333 log << m_statPrintLevel << m_statEntities[statTag] << endmsg;
334 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:157
ChronoStatSvc::m_statPrintLevel
MSG::Level m_statPrintLevel
level of info printing
Definition: ChronoStatSvc.h:159
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## Member Data Documentation

## ◆ m_chronoCoutFlag

Gaudi::Property<bool> ChronoStatSvc::m_chronoCoutFlag
| private

Initial value:
{this, "ChronoDestinationCout", false,
"define the destination of the table to be printed"}

Definition at line 163 of file ChronoStatSvc.h.

## ◆ m_chronoEntities

ChronoMap ChronoStatSvc::m_chronoEntities
| private

chrono part

Definition at line 145 of file ChronoStatSvc.h.

## ◆ m_chronoOrderFlag

Gaudi::Property<bool> ChronoStatSvc::m_chronoOrderFlag {this, "ChronoTableToBeOrdered", true, "should the printout be ordered"}
| private

Definition at line 168 of file ChronoStatSvc.h.

## ◆ m_chronoPrintLevel

MSG::Level ChronoStatSvc::m_chronoPrintLevel = MSG::INFO
| private

level of info printing

Definition at line 154 of file ChronoStatSvc.h.

## ◆ m_chronoTableFlag

Gaudi::Property<bool> ChronoStatSvc::m_chronoTableFlag
| private

Initial value:
{this, "ChronoPrintOutTable", true,
"decide if the final printout should be performed"}

Definition at line 161 of file ChronoStatSvc.h.

## ◆ m_header

Gaudi::Property<std::string> ChronoStatSvc::m_header
| private

Initial value:
{
this, "StatTableHeader",
" | Counter | # | sum | mean/eff^* | rms/err^* | min | max |",
"The header row for the output Stat-table"}

Definition at line 185 of file ChronoStatSvc.h.

## ◆ m_hiveWhiteBoardSvc

ServiceHandle<IInterface> ChronoStatSvc::m_hiveWhiteBoardSvc {this, "HiveWhiteBoardSvc", "EventDataSvc"}
| private

Definition at line 194 of file ChronoStatSvc.h.

## ◆ m_intChronoPrintLevel

Gaudi::Property<int> ChronoStatSvc::m_intChronoPrintLevel
| private

Initial value:
{
this, "ChronoPrintLevel", MSG::INFO, [this]( auto& ) { m_chronoPrintLevel = int2level( m_intChronoPrintLevel ); },
"print level"}

Definition at line 165 of file ChronoStatSvc.h.

## ◆ m_intStatPrintLevel

Gaudi::Property<int> ChronoStatSvc::m_intStatPrintLevel
| private

Initial value:
{this, "StatPrintLevel", MSG::INFO,
[this]( auto& ) { m_statPrintLevel = int2level( m_intStatPrintLevel ); },
"print level"}

Definition at line 176 of file ChronoStatSvc.h.

## ◆ m_mutex

std::mutex ChronoStatSvc::m_mutex
| mutable private

Mutex protecting m_chronoEntities.

Definition at line 150 of file ChronoStatSvc.h.

## ◆ m_ofd

std::ofstream ChronoStatSvc::m_ofd
| private

Definition at line 198 of file ChronoStatSvc.h.

## ◆ m_perEventFile

Gaudi::Property<std::string> ChronoStatSvc::m_perEventFile {this, "PerEventFile", "", "File name for per-event deltas"}
| private

Definition at line 192 of file ChronoStatSvc.h.

## ◆ m_perEvtTime

TimeMap ChronoStatSvc::m_perEvtTime
| private

Definition at line 197 of file ChronoStatSvc.h.

## ◆ m_printEllapsedTime

Gaudi::Property<bool> ChronoStatSvc::m_printEllapsedTime {this, "PrintEllapsedTime", false}
| private

Definition at line 171 of file ChronoStatSvc.h.

## ◆ m_printSystemTime

Gaudi::Property<bool> ChronoStatSvc::m_printSystemTime {this, "PrintSystemTime", false}
| private

Definition at line 170 of file ChronoStatSvc.h.

## ◆ m_printUserTime

Gaudi::Property<bool> ChronoStatSvc::m_printUserTime {this, "PrintUserTime", true}
| private

Definition at line 169 of file ChronoStatSvc.h.

## ◆ m_statCoutFlag

Gaudi::Property<bool> ChronoStatSvc::m_statCoutFlag
| private

Initial value:
{this, "StatDestinationCout", false,
"define the destination of the table to be printed"}

Definition at line 174 of file ChronoStatSvc.h.

## ◆ m_statEntities

StatMap ChronoStatSvc::m_statEntities
| private

stat part

Definition at line 157 of file ChronoStatSvc.h.

## ◆ m_statOrderFlag

Gaudi::Property<bool> ChronoStatSvc::m_statOrderFlag {this, "StatTableToBeOrdered", true, "should the printout be ordered"}
| private

Definition at line 179 of file ChronoStatSvc.h.

## ◆ m_statPrintLevel

MSG::Level ChronoStatSvc::m_statPrintLevel = MSG::INFO
| private

level of info printing

Definition at line 159 of file ChronoStatSvc.h.

## ◆ m_statsOutFileName

Gaudi::Property<std::string> ChronoStatSvc::m_statsOutFileName
| private

Initial value:
{
this, "AsciiStatsOutputFile", "",
"Name of the output file storing the stats. If empty, no statistics will be saved (default)"}

Definition at line 181 of file ChronoStatSvc.h.

## ◆ m_statTableFlag

Gaudi::Property<bool> ChronoStatSvc::m_statTableFlag
| private

Initial value:
{this, "StatPrintOutTable", true,
"decide if the final printout should be performed"}

Definition at line 172 of file ChronoStatSvc.h.

## ◆ m_useEffFormat

Gaudi::Property<bool> ChronoStatSvc::m_useEffFormat
| private

Initial value:
{this, "UseEfficiencyRowFormat", true,
"Use the special format for printout of efficiency counters"}

Definition at line 189 of file ChronoStatSvc.h.

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

- GaudiCommonSvc/src/ChronoStatSvc.h
- GaudiCommonSvc/src/ChronoStatSvc.cpp