| The Gaudi Framework v27r1

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

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

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 <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
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
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...
virtual ChronoEntity * | chronoStart (const IChronoStatSvc::ChronoTag &chronoTag) override
| Implementation of IChronoStatSvc::chronoStart. More...
virtual const ChronoEntity * | chronoStop (const IChronoStatSvc::ChronoTag &chronoTag) override
| Implementation of IChronoStatSvc::chronoStop. More...
virtual IChronoStatSvc::ChronoTime | chronoDelta (const IChronoStatSvc::ChronoTag &chronoTag, IChronoStatSvc::ChronoType theType) override
| Implementation of IchronoStatSvc::chronoDelta. More...
virtual void | chronoPrint (const IChronoStatSvc::ChronoTag &chronoTag) override
| Implementation of IChronoStatSvc::chronoPrint. More...
virtual ChronoStatus | chronoStatus (const IChronoStatSvc::ChronoTag &chronoTag) override
| Implementation of IChronoStatSvc::chronoStatus. More...
virtual 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...
virtual void | statPrint (const IChronoStatSvc::ChronoTag &statTag) override
| prints (using message service) info about statistical entity, tagged by its name More...
virtual const ChronoEntity * | chrono (const IChronoStatSvc::ChronoTag &t) const override
| extract the chrono entity for the given tag (name) More...
virtual const StatEntity * | stat (const IChronoStatSvc::StatTag &t) const 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...
| ~ChronoStatSvc () override=default
| Destructor. 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...
| ~extends () override=default
| Virtual destructor. 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...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value 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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. More...
template<class T >
StatusCode | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public 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 CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
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...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces...>
| ~extend_interfaces () override=default
| Virtual destructor. 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 CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

## Private Types
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...

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

## Additional Inherited Members
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. 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 : 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 39 of file ChronoStatSvc.h.

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

Definition at line 40 of file ChronoStatSvc.h.

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

Definition at line 192 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 60 of file ChronoStatSvc.cpp.

61 : base_class( name , svcloc )
62 //
63 // the header row
64 , m_header ( " Counter | # | sum | mean/eff^* | rms/err^* | min | max |")
65 // format for regular statistical printout rows
66 , m_format1 ( " %|-15.15s|%|17t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" )
67 // format for "efficiency" statistical printout rows
68 , m_format2 ( "*%|-15.15s|%|17t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%| ------- | ------- |" )
69 {
71 declareProperty ( "ChronoPrintOutTable" ,
72 m_chronoTableFlag = true );
74 declareProperty ( "ChronoDestinationCout" ,
75 m_chronoCoutFlag = false );
77 declareProperty ( "ChronoPrintLevel" ,
78 m_intChronoPrintLevel = MSG::INFO );
81 declareProperty ( "ChronoTableToBeOrdered" ,
82 m_chronoOrderFlag = true );
84 declareProperty ( "PrintUserTime" ,
85 m_printUserTime = true );
87 declareProperty ( "PrintSystemTime" ,
88 m_printSystemTime = false );
90 declareProperty ( "PrintEllapsedTime" ,
91 m_printEllapsedTime = false );
94 declareProperty ( "StatPrintOutTable" ,
95 m_statTableFlag = true );
97 declareProperty ( "StatDestinationCout" ,
98 m_statCoutFlag = false );
100 declareProperty ( "StatPrintLevel" ,
101 m_intStatPrintLevel = MSG::INFO );
104 declareProperty ( "StatTableToBeOrdered" ,
105 m_statOrderFlag = true );
106
107 // specify the number of events to be skipped by the memory auditor
108 // in order to better spot memory leak
109 declareProperty ( "NumberOfSkippedEventsForMemStat" ,
110 m_numberOfSkippedEventsForMemStat = -1 ) ;
111
112 declareProperty( "AsciiStatsOutputFile",
113 m_statsOutFileName = "",
114 "Name of the output file storing the stats. If empty, no"
115 " statistics will be saved (default)" );
116
117 declareProperty
118 ( "StatTableHeader" , m_header ,
119 "The header row for the output Stat-table" ) ;
120 declareProperty
121 ( "RegularRowFormat" , m_format1 ,
122 "The format for the regular row in the output Stat-table" ) ;
123 declareProperty
124 ( "EfficiencyRowFormat" , m_format2 ,
125 "The format for the regular row in the output Stat-table" ) ;
126 declareProperty
127 ( "UseEfficiencyRowFormat" , m_useEffFormat ,
128 "Use the special format for printout of efficiency counters" ) ;
129
130 declareProperty
131 ( "PerEventFile", m_perEventFile="",
132 "File name for per-event deltas" );
133
134 }
ChronoStatSvc::m_useEffFormat
bool m_useEffFormat
flag to use the special "efficiency" format
Definition: ChronoStatSvc.h:190
ChronoStatSvc::m_intStatPrintLevel
int m_intStatPrintLevel
level of info printing
Definition: ChronoStatSvc.h:170
ChronoStatSvc::m_chronoOrderFlag
bool m_chronoOrderFlag
flag for formattion the final statistic table
Definition: ChronoStatSvc.h:155
ChronoStatSvc::m_printUserTime
bool m_printUserTime
flag for printing User quantities
Definition: ChronoStatSvc.h:157
ChronoStatSvc::m_printEllapsedTime
bool m_printEllapsedTime
flag for printing Ellapsed quantities
Definition: ChronoStatSvc.h:161
ChronoStatSvc::m_header
std::string m_header
the header row
Definition: ChronoStatSvc.h:184
ChronoStatSvc::m_statsOutFileName
StringProperty m_statsOutFileName
Name of the output file where we'll dump the stats.
Definition: ChronoStatSvc.h:181
extends< Service, IChronoStatSvc, IIncidentListener >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
ChronoStatSvc::m_numberOfSkippedEventsForMemStat
long m_numberOfSkippedEventsForMemStat
Definition: ChronoStatSvc.h:164
ChronoStatSvc::m_format2
std::string m_format2
format for "efficiency" statistical printout rows
Definition: ChronoStatSvc.h:188
ChronoStatSvc::m_chronoTableFlag
bool m_chronoTableFlag
flag for printing the final table
Definition: ChronoStatSvc.h:151
ChronoStatSvc::m_intChronoPrintLevel
int m_intChronoPrintLevel
level of info printing
Definition: ChronoStatSvc.h:148
ChronoStatSvc::m_statOrderFlag
bool m_statOrderFlag
flag for formattion the final statistic table
Definition: ChronoStatSvc.h:177
ChronoStatSvc::m_statTableFlag
bool m_statTableFlag
flag for printing the final table
Definition: ChronoStatSvc.h:173
ChronoStatSvc::m_statCoutFlag
bool m_statCoutFlag
flag for destination of the t he final table
Definition: ChronoStatSvc.h:175
ChronoStatSvc::m_printSystemTime
bool m_printSystemTime
flag for printing System quantities
Definition: ChronoStatSvc.h:159
ChronoStatSvc::m_perEventFile
std::string m_perEventFile
Definition: ChronoStatSvc.h:194
ChronoStatSvc::m_chronoCoutFlag
bool m_chronoCoutFlag
flag for destination of the the final table
Definition: ChronoStatSvc.h:153
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
MSG::INFO
Definition: IMessageSvc.h:19
ChronoStatSvc::m_format1
std::string m_format1
format for regular statistical printout rows
Definition: ChronoStatSvc.h:186

ChronoStatSvc::~ChronoStatSvc | ( |  | ) |
| override default

Destructor.

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

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

## Member Function Documentation

const ChronoEntity * ChronoStatSvc::chrono | ( | const IChronoStatSvc::ChronoTag & | t | ) | const
| override 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 482 of file ChronoStatSvc.cpp.

483 {
484 auto it = m_chronoEntities.find ( t ) ;
485 return m_chronoEntities.end() != it ? &(it->second) : nullptr;
486 }
std::map::end
T end(T...args)
std::map::find
T find(T...args)
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

Implementation of IchronoStatSvc::chronoDelta.

See also
  IChronoStatSvc

Definition at line 410 of file ChronoStatSvc.cpp.

412 {
413 return m_chronoEntities[ chronoTag ].delta( theType );
414 }
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

Implementation of IChronoStatSvc::chronoPrint.

See also
  IChronoStatSvc

Definition at line 419 of file ChronoStatSvc.cpp.

420 {
421 MsgStream log ( msgSvc() , chronoTag );
422 if( m_printUserTime ) {
423 log << (MSG::Level) m_chronoPrintLevel
424 << m_chronoEntities[ chronoTag ].outputUserTime ()
425 << endmsg;
426 }
427 if( m_printSystemTime ) {
428 log << (MSG::Level) m_chronoPrintLevel
429 << m_chronoEntities[ chronoTag ].outputSystemTime()
430 << endmsg;
431 }
432 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
ChronoStatSvc::m_printUserTime
bool m_printUserTime
flag for printing User quantities
Definition: ChronoStatSvc.h:157
Gaudi.Configuration.log
tuple log
Definition: Configuration.py:13
MSG::Level
Level
Definition: IMessageSvc.h:15
ChronoStatSvc::m_chronoPrintLevel
MSG::Level m_chronoPrintLevel
Definition: ChronoStatSvc.h:149
ChronoStatSvc::m_printSystemTime
bool m_printSystemTime
flag for printing System quantities
Definition: ChronoStatSvc.h:159
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

Implementation of IChronoStatSvc::chronoStart.

See also
  IChronoStatSvc

Definition at line 388 of file ChronoStatSvc.cpp.

389 {
390 ChronoEntity& entity = m_chronoEntities [ chronoTag ] ;
391 entity.start() ;
392 return &entity ;
393 }
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:47
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

Implementation of IChronoStatSvc::chronoStatus.

See also
  IChronoStatSvc

Definition at line 438 of file ChronoStatSvc.cpp.

439 { return m_chronoEntities[ chronoTag ].status(); }
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

Implementation of IChronoStatSvc::chronoStop.

See also
  IChronoStatSvc

Definition at line 399 of file ChronoStatSvc.cpp.

400 {
401 ChronoEntity& entity = m_chronoEntities [ chronoTag ] ;
402 entity.stop() ;
403 return &entity ;
404 }
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:63
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

230 {
231 std::string local = name()+".finalize()";
233 MsgStream main_log( msgSvc() , local );
236 chronoStop( name() ) ;
237
238 if (m_ofd.is_open()) {
239 debug() << "writing per-event timing data to '" << m_perEventFile << "'" << endmsg;
240 for (const auto& itr:m_perEvtTime) {
241 m_ofd << itr.first.substr(0,itr.first.length()-8 ) << " ";
242 for (const auto& itt:itr.second) {
243 m_ofd << " " << (long int)(itt);
244 }
245 m_ofd << std::endl;
246 }
247
248 m_ofd.close();
249 }
250
253 if ( m_chronoTableFlag &&
254 !m_chronoEntities.empty() &&
255 ( m_printUserTime || m_printSystemTime ) )
256 {
258 MsgStream log( msgSvc() , "*****Chrono*****" );
259 const std::string stars( ( m_chronoCoutFlag ) ? 126 : 100 , '*' );
260 if( m_chronoCoutFlag )
261 {
262 std::cout << stars << std::endl;
263 std::cout << local << " The Final CPU consumption (Chrono) Table "
264 << ( m_chronoOrderFlag ? "(ordered)" : "(not ordered)" ) << std::endl;
265 std::cout << stars << std::endl;
266 }
267 else
268 {
269 log << (MSG::Level) m_chronoPrintLevel
270 << stars << endmsg;
271 log << (MSG::Level) m_chronoPrintLevel
272 << " The Final CPU consumption ( Chrono ) Table "
273 << ( m_chronoOrderFlag ? "(ordered)" : "(not ordered)" ) << endmsg;
274 log << (MSG::Level) m_chronoPrintLevel << stars << endmsg;
275 }
277 { // prepare container for printing
278 std::vector<std::pair<ChronoEntity*,const ChronoTag*>> tmpCont;
279 tmpCont.reserve(m_chronoEntities.size());
280 for( auto& it : m_chronoEntities )
281 { tmpCont.emplace_back( &it.second , &it.first ) ; }
282 // sort it
283 if( m_chronoOrderFlag ) std::sort( tmpCont.begin(), tmpCont.end(),
284 CompareFirstOfPointerPair );
285 // print User Time statistics
286 if( m_printUserTime )
287 {
288 for( auto iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
289 {
290 //
291 ChronoEntity* entity = iter->first ; if( !entity ) { continue ; }
292 const ChronoTag* tag = iter->second ; if( !tag ) { continue ; }
293 entity->stop();
295 if ( m_chronoCoutFlag )
297 { std::cout << *tag << "\t" << entity->outputUserTime () << std::endl ; }
298 else
299 {
300 MsgStream(msgSvc(), *tag)
301 << m_chronoPrintLevel << entity->outputUserTime () << endmsg ;
302 }
303 //
304 }
305 }
307 if( m_printSystemTime )
308 {
311 if ( m_printUserTime && m_chronoCoutFlag )
312 { std::cout << stars << std::endl; }
313 else if ( m_printUserTime && !m_chronoCoutFlag )
314 { log << (MSG::Level) m_chronoPrintLevel << stars << endmsg; }
316 for( auto iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
317 {
319 ChronoEntity* entity = iter->first ; if( !entity ) { continue ; }
320 const ChronoTag* tag = iter->second ; if( !tag ) { continue ; }
321 entity->stop();
323 if ( m_chronoCoutFlag )
325 { std::cout << *tag << "\t" << entity->outputSystemTime() << std::endl ; }
326 else
327 {
328 MsgStream(msgSvc(), *tag)
329 << m_chronoPrintLevel << entity->outputSystemTime() << endmsg ;
330 }
331 //
332 }
333 }
335 if( m_printEllapsedTime )
336 {
339 if ( ( m_printUserTime || m_printSystemTime ) && m_chronoCoutFlag )
340 { std::cout << stars << std::endl; }
341 else if ( ( m_printUserTime || m_printSystemTime ) && !m_chronoCoutFlag )
342 { log << (MSG::Level) m_chronoPrintLevel << stars << endmsg; }
344 for( const auto& i : tmpCont )
345 {
347 ChronoEntity* entity = i.first ; if( !entity ) { continue ; }
348 const ChronoTag* tag = i.second ; if( !tag ) { continue ; }
349 entity->stop();
351 if ( m_chronoCoutFlag )
353 { std::cout << *tag << "\t" << entity->outputElapsedTime() << std::endl ; }
354 else
355 {
356 MsgStream(msgSvc(), *tag)
357 << m_chronoPrintLevel << entity->outputElapsedTime() << endmsg ;
358 }
359 //
360 }
361 }
363 tmpCont.clear();
364 }
366 if( m_chronoCoutFlag ) { std::cout << stars << std::endl; }
367 else { log << m_chronoPrintLevel << stars << endmsg; }
368 }
369
371
373 if ( m_statTableFlag ) { printStats () ; }
374
375 if ( !m_statsOutFileName.value().empty() ) {
376 saveStats();
377 }
378
379 main_log << MSG::INFO << " Service finalized successfully " << endmsg;
380
381 return Service::finalize();
382 }
ChronoEntity::outputElapsedTime
std::string outputElapsedTime() const
print the chrono ;
Definition: ChronoEntity.cpp:110
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::map::empty
T empty(T...args)
ChronoStatSvc::m_chronoOrderFlag
bool m_chronoOrderFlag
flag for formattion the final statistic table
Definition: ChronoStatSvc.h:155
ChronoStatSvc::m_printUserTime
bool m_printUserTime
flag for printing User quantities
Definition: ChronoStatSvc.h:157
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:193
ChronoStatSvc::m_printEllapsedTime
bool m_printEllapsedTime
flag for printing Ellapsed quantities
Definition: ChronoStatSvc.h:161
Gaudi.Configuration.log
tuple log
Definition: Configuration.py:13
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_statsOutFileName
StringProperty m_statsOutFileName
Name of the output file where we'll dump the stats.
Definition: ChronoStatSvc.h:181
std::vector::end
T end(T...args)
ChronoEntity::outputSystemTime
std::string outputSystemTime() const
print the chrono ;
Definition: ChronoEntity.cpp:98
ChronoStatSvc::m_chronoTableFlag
bool m_chronoTableFlag
flag for printing the final table
Definition: ChronoStatSvc.h:151
std::string
STL class.
ChronoStatSvc::printStats
void printStats()
Definition: ChronoStatSvc.cpp:576
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
MSG::Level
Level
Definition: IMessageSvc.h:15
ChronoStatSvc::saveStats
void saveStats()
dump the statistics into an ASCII file for offline processing
Definition: ChronoStatSvc.cpp:503
CompareFirstOfPointerPair
constexpr struct CompareFirstOfPointerPair_t CompareFirstOfPointerPair
MsgStream::clear
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:222
ChronoStatSvc::m_perEvtTime
TimeMap m_perEvtTime
Definition: ChronoStatSvc.h:193
std::ofstream::close
T close(T...args)
ChronoStatSvc::chronoStop
virtual const ChronoEntity * chronoStop(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStop.
Definition: ChronoStatSvc.cpp:399
ChronoStatSvc::m_ofd
std::ofstream m_ofd
Definition: ChronoStatSvc.h:195
ChronoStatSvc::m_statTableFlag
bool m_statTableFlag
flag for printing the final table
Definition: ChronoStatSvc.h:173
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
ChronoStatSvc::m_chronoPrintLevel
MSG::Level m_chronoPrintLevel
Definition: ChronoStatSvc.h:149
ChronoEntity::outputUserTime
std::string outputUserTime() const
print the chrono ;
Definition: ChronoEntity.cpp:85
std::map::size
T size(T...args)
std::vector
STL class.
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:127
ChronoStatSvc::m_printSystemTime
bool m_printSystemTime
flag for printing System quantities
Definition: ChronoStatSvc.h:159
std::vector::begin
T begin(T...args)
ChronoStatSvc::m_perEventFile
std::string m_perEventFile
Definition: ChronoStatSvc.h:194
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
std::sort
T sort(T...args)
ChronoStatSvc::m_chronoCoutFlag
bool m_chronoCoutFlag
flag for destination of the the final table
Definition: ChronoStatSvc.h:153
std::ofstream::is_open
T is_open(T...args)
MSG::INFO
Definition: IMessageSvc.h:19
ChronoEntity::stop
IChronoSvc::ChronoStatus stop()
stop the chrono
Definition: ChronoEntity.cpp:63
ana.i
list i
Definition: ana.py:128
std::cout
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector::reserve
T reserve(T...args)
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146
std::vector::emplace_back
T emplace_back(T...args)

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

Definition at line 649 of file ChronoStatSvc.cpp.

649 {
650
651 if (! m_ofd.is_open()) return;
652
653 for (const auto& itr:m_chronoEntities) {
654 if (itr.first.find(":Execute") == std::string::npos) continue;
655
656 auto itm = m_perEvtTime.find(itr.first);
657 if (itm == m_perEvtTime.end()) {
658 m_perEvtTime[itr.first] = { itr.second.delta(IChronoSvc::ELAPSED) };
659 } else {
660 itm->second.push_back( itr.second.delta(IChronoSvc::ELAPSED) );
661 }
662 }
663 }
ana.itm
tuple itm
Definition: ana.py:57
std::map::end
T end(T...args)
ChronoStatSvc::m_perEvtTime
TimeMap m_perEvtTime
Definition: ChronoStatSvc.h:193
ChronoStatSvc::m_ofd
std::ofstream m_ofd
Definition: ChronoStatSvc.h:195
IChronoSvc::ELAPSED
Definition: IChronoSvc.h:57
std::map::find
T find(T...args)
std::ofstream::is_open
T is_open(T...args)
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

Implementation of IService::initialize()

redefine some "properties"

start its own chrono

Definition at line 166 of file ChronoStatSvc.cpp.

167 {
168 StatusCode sc = Service::initialize();
169 if ( sc.isFailure() ) return sc;
171 // Set my own properties
172 sc = setProperties();
173
174 if (sc.isFailure()) {
175 error() << "setting my properties" << endmsg;
176 return StatusCode::FAILURE;
177 }
178
179 // only add an EndEvent listener if per-event output requested
180 if (!m_perEventFile.empty()) {
181 m_ofd.open(m_perEventFile);
182 if (!m_ofd.is_open()) {
183 error() << "unable to open per-event output file \""
184 << m_perEventFile << "\"" << endmsg;
185 return StatusCode::FAILURE;
186 } else {
187 auto ii = serviceLocator()->service<IIncidentSvc>("IncidentSvc");
188 if ( !ii) {
189 error() << "Unable to find IncidentSvc" << endmsg;
190 return StatusCode::FAILURE;
191 }
192 ii->addListener(this, IncidentType::EndEvent);
193 }
194 }
195
196 info() << " Number of skipped events for MemStat"
197 << m_numberOfSkippedEventsForMemStat << endmsg ;
198
202 m_statPrintLevel =
203 ( MSG::FATAL < m_intStatPrintLevel ) ? MSG::FATAL :
204 ( MSG::NIL > m_intStatPrintLevel ) ? MSG::NIL :
205 ( MSG::Level ) m_intStatPrintLevel ;
207 m_chronoPrintLevel =
208 ( MSG::FATAL < m_intChronoPrintLevel ) ? MSG::FATAL :
209 ( MSG::NIL > m_intChronoPrintLevel ) ? MSG::NIL :
210 ( MSG::Level ) m_intChronoPrintLevel ;
212 if( m_chronoTableFlag &&
213 !m_printUserTime &&
214 !m_printSystemTime &&
215 !m_printEllapsedTime ) { m_printUserTime = true ; }
217 if( m_printUserTime ||
218 m_printSystemTime ||
219 m_printEllapsedTime ) { m_chronoTableFlag = true ; }
222 chronoStart( name() ) ;
224 return StatusCode::SUCCESS;
225 }
ChronoStatSvc::m_intStatPrintLevel
int m_intStatPrintLevel
level of info printing
Definition: ChronoStatSvc.h:170
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
std::string::empty
T empty(T...args)
std::ofstream::open
T open(T...args)
ChronoStatSvc::m_printUserTime
bool m_printUserTime
flag for printing User quantities
Definition: ChronoStatSvc.h:157
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
ChronoStatSvc::m_printEllapsedTime
bool m_printEllapsedTime
flag for printing Ellapsed quantities
Definition: ChronoStatSvc.h:161
merge_files.sc
int sc
Definition: merge_files.py:167
ChronoStatSvc::m_numberOfSkippedEventsForMemStat
long m_numberOfSkippedEventsForMemStat
Definition: ChronoStatSvc.h:164
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
ChronoStatSvc::m_chronoTableFlag
bool m_chronoTableFlag
flag for printing the final table
Definition: ChronoStatSvc.h:151
ChronoStatSvc::m_intChronoPrintLevel
int m_intChronoPrintLevel
level of info printing
Definition: ChronoStatSvc.h:148
MSG::FATAL
Definition: IMessageSvc.h:22
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:78
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
MSG::Level
Level
Definition: IMessageSvc.h:15
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:118
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
MSG::NIL
Definition: IMessageSvc.h:16
ChronoStatSvc::m_ofd
std::ofstream m_ofd
Definition: ChronoStatSvc.h:195
Service::setProperties
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:363
ChronoStatSvc::m_chronoPrintLevel
MSG::Level m_chronoPrintLevel
Definition: ChronoStatSvc.h:149
ChronoStatSvc::m_printSystemTime
bool m_printSystemTime
flag for printing System quantities
Definition: ChronoStatSvc.h:159
ChronoStatSvc::chronoStart
virtual ChronoEntity * chronoStart(const IChronoStatSvc::ChronoTag &chronoTag) override
Implementation of IChronoStatSvc::chronoStart.
Definition: ChronoStatSvc.cpp:388
ChronoStatSvc::m_perEventFile
std::string m_perEventFile
Definition: ChronoStatSvc.h:194
ChronoStatSvc::m_statPrintLevel
MSG::Level m_statPrintLevel
Definition: ChronoStatSvc.h:171
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:244
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21

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

Compound assignment operator.

Definition at line 138 of file ChronoStatSvc.cpp.

138 {
139
140 // Add the content of the maps, leave the rest unchanged
141
142 // Merge Chronomaps
143 for (auto& item : css.m_chronoEntities){
144 const IChronoStatSvc::ChronoTag& key = item.first;
145 const ChronoEntity& val = item.second;
146 if (m_chronoEntities.count(key))
147 m_chronoEntities[key]+=val;
148 else
149 m_chronoEntities.insert (std::pair<IChronoStatSvc::ChronoTag,ChronoEntity>(key,val));
150 }
151
152 // Merge StatMaps
153 for (auto& item : css.m_statEntities){
154 const IChronoStatSvc::StatTag& key = item.first;
155 const StatEntity& val = item.second;
156 if (m_statEntities.count(key))
157 m_statEntities[key]+=val;
158 else
159 m_statEntities.insert (std::pair<IChronoStatSvc::StatTag,StatEntity>(key,val));
160 }
161
162 }
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:167
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
std::map::count
T count(T...args)
std::pair
std::map::insert
T insert(T...args)
ana.item
tuple item
print s1,s2
Definition: ana.py:146
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:64
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

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

nothing to print?

CONTINUE

CONTINUE

decoration

Definition at line 576 of file ChronoStatSvc.cpp.

577 {
579 if ( m_statEntities.empty() ) { return ; }
580
581 MsgStream log ( msgSvc() , "******Stat******" ) ;
583 const std::string stars( ( m_statCoutFlag ) ? 126 : 100 , '*' ) ;
585 if ( m_statCoutFlag )
586 {
587 std::cout << stars << std::endl;
588 std::cout << " The Final stat Table "
589 << ( m_statOrderFlag ? "(ordered)" : "(not ordered)" ) << std::endl;
590 std::cout << stars << std::endl;
591 }
592 else
593 {
594 log << m_statPrintLevel << stars << endmsg;
595 log << m_statPrintLevel << " The Final stat Table "
596 << ( m_statOrderFlag ? "(ordered)" : "(not ordered)" ) << endmsg;
597 log << m_statPrintLevel << stars << endmsg;
598 }
599
600 {
601 // prepare container for printing
602 typedef std::pair<const StatEntity*,const StatTag*> SPair;
603 typedef std::vector<SPair> SCont;
604 SCont tmpCont;
605 std::transform( std::begin(m_statEntities), std::end(m_statEntities),
606 std::back_inserter(tmpCont),
607 [](StatMap::const_reference i)
608 { return std::make_pair( &i.second, &i.first); } );
609 // sort it
610 if ( m_statOrderFlag ) std::sort( tmpCont.begin(), tmpCont.end(),
611 CompareFirstOfPointerPair );
612 // print the table header
613 if ( m_statCoutFlag ) { std::cout << m_header << std::endl ; }
614 else { log << m_statPrintLevel << m_header << endmsg ; }
615
616 // loop over counters and print them:
617 for ( const auto& iter : tmpCont ) {
619 const StatEntity* entity = iter.first ;
620 if ( !entity ) { continue ; }
621 const StatTag* tag = iter.second ;
622 if ( !tag ) { continue ; }
623 if ( m_statCoutFlag )
625 {
626 std::cout
627 << Gaudi::Utils::formatAsTableRow
628 ( *tag , *entity , m_useEffFormat , m_format1 , m_format2 )
629 << std::endl;
630 }
631 else
632 {
633 log
634 << m_statPrintLevel
635 << Gaudi::Utils::formatAsTableRow
636 ( *tag , *entity , m_useEffFormat , m_format1 , m_format2 )
637 << endmsg ;
638 }
639 }
640 tmpCont.clear();
641 }
643 if ( m_statCoutFlag ) { std::cout << stars << std::endl; }
644 else { log << m_statPrintLevel << stars << endmsg; }
645 }
ChronoStatSvc::m_useEffFormat
bool m_useEffFormat
flag to use the special "efficiency" format
Definition: ChronoStatSvc.h:190
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::map::empty
T empty(T...args)
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:167
Gaudi.Configuration.log
tuple log
Definition: Configuration.py:13
ChronoStatSvc::m_header
std::string m_header
the header row
Definition: ChronoStatSvc.h:184
std::endl
T endl(T...args)
std::end
T end(T...args)
ChronoStatSvc::m_format2
std::string m_format2
format for "efficiency" statistical printout rows
Definition: ChronoStatSvc.h:188
Gaudi::Utils::formatAsTableRow
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
Definition: StatEntity.cpp:299
std::string
STL class.
ChronoStatSvc::m_statOrderFlag
bool m_statOrderFlag
flag for formattion the final statistic table
Definition: ChronoStatSvc.h:177
CompareFirstOfPointerPair
constexpr struct CompareFirstOfPointerPair_t CompareFirstOfPointerPair
MsgStream::clear
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:222
std::make_pair
T make_pair(T...args)
std::pair
std::vector
STL class.
ChronoStatSvc::m_statCoutFlag
bool m_statCoutFlag
flag for destination of the t he final table
Definition: ChronoStatSvc.h:175
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
ChronoStatSvc::m_statPrintLevel
MSG::Level m_statPrintLevel
Definition: ChronoStatSvc.h:171
std::sort
T sort(T...args)
std::transform
T transform(T...args)
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:64
ana.i
list i
Definition: ana.py:128
std::cout
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
ChronoStatSvc::m_format1
std::string m_format1
format for regular statistical printout rows
Definition: ChronoStatSvc.h:186

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

dump the statistics into an ASCII file for offline processing

CONTINUE

CONTINUE

Definition at line 503 of file ChronoStatSvc.cpp.

504 {
505 std::ofstream out( m_statsOutFileName.value(),
506 std::ios_base::out | std::ios_base::trunc );
507 if ( !out.good() ) {
508 info()
509 << "Could not open the output file for writing chrono statistics ["
510 << m_statsOutFileName.value() << "]"
511 << endmsg;
512 return;
513 } else {
514 // format it our way
515 out << std::scientific << std::setprecision(8) ;
516 }
517
518 // ChronoEntity
519 std::vector<std::pair<const ChronoEntity*, const ChronoTag*> > chronos;
520 chronos.reserve(m_chronoEntities.size() );
521 std::transform( std::begin(m_chronoEntities), std::end(m_chronoEntities),
522 std::back_inserter(chronos),
523 [](ChronoMap::const_reference i)
524 { return std::make_pair( &i.second, &i.first ); } );
525
526 // sort it
527 std::sort( std::begin(chronos) ,
528 std::end(chronos) ,
529 CompareFirstOfPointerPair );
530
531 // print User Time statistics
532 for( const auto& iter : chronos ) {
533 //
534 const ChronoEntity* entity = iter.first;
535 if( !entity ) { continue ; }
536
537 const ChronoTag* tag = iter.second ;
538 if( !tag ) { continue ; }
539
540 // create an entry in the .INI-like table
541 out << "\n[" << *tag << "]\n";
542
543 // user
544 out << "cpu_user_total = " << entity->uTotalTime() << "\n";
545 out << "cpu_user_min = " << entity->uMinimalTime() << "\n";
546 out << "cpu_user_mean = " << entity->uMeanTime() << "\n";
547 out << "cpu_user_RMS = " << entity->uRMSTime() << "\n";
548 out << "cpu_user_max = " << entity->uMaximalTime() << "\n";
549 out << "cpu_user_nbr = " << entity->nOfMeasurements() << "\n";
550
551 // system
552 out << "\n"; // just for clarity
553 out << "cpu_system_total = " << entity->kTotalTime() << "\n";
554 out << "cpu_system_min = " << entity->kMinimalTime() << "\n";
555 out << "cpu_system_mean = " << entity->kMeanTime() << "\n";
556 out << "cpu_system_RMS = " << entity->kRMSTime() << "\n";
557 out << "cpu_system_max = " << entity->kMaximalTime() << "\n";
558 out << "cpu_system_nbr = " << entity->nOfMeasurements() << "\n";
559
560 // real
561 out << "\n"; // just for clarity
562 out << "cpu_real_total = " << entity->eTotalTime() << "\n";
563 out << "cpu_real_min = " << entity->eMinimalTime() << "\n";
564 out << "cpu_real_mean = " << entity->eMeanTime() << "\n";
565 out << "cpu_real_RMS = " << entity->eRMSTime() << "\n";
566 out << "cpu_real_max = " << entity->eMaximalTime() << "\n";
567 out << "cpu_real_nbr = " << entity->nOfMeasurements() << "\n";
568
569 }
570
571 out << std::endl;
572 }
ChronoEntity::kMaximalTime
double kMaximalTime() const
maximal measurement for kernel time
Definition: ChronoEntity.h:219
ChronoEntity::uMinimalTime
double uMinimalTime() const
minimal measurement for user time
Definition: ChronoEntity.h:198
ChronoEntity::uTotalTime
double uTotalTime() const
total user time
Definition: ChronoEntity.h:229
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:124
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
ChronoEntity::kTotalTime
double kTotalTime() const
total Kernel time
Definition: ChronoEntity.h:234
std::endl
T endl(T...args)
ChronoStatSvc::m_statsOutFileName
StringProperty m_statsOutFileName
Name of the output file where we'll dump the stats.
Definition: ChronoStatSvc.h:181
ChronoEntity::uRMSTime
double uRMSTime() const
r.m.s User Time
Definition: ChronoEntity.h:270
std::end
T end(T...args)
ChronoEntity::kMinimalTime
double kMinimalTime() const
minimal measurement for kernel time
Definition: ChronoEntity.h:204
ChronoEntity::eMinimalTime
double eMinimalTime() const
minimal measurement for elapsed time
Definition: ChronoEntity.h:209
ChronoEntity::kRMSTime
double kRMSTime() const
r.m.s Kernel Time
Definition: ChronoEntity.h:265
ChronoEntity::kMeanTime
double kMeanTime() const
average Kernel Time
Definition: ChronoEntity.h:250
std::ofstream
STL class.
ChronoEntity::eMeanTime
double eMeanTime() const
average Elapsed Time
Definition: ChronoEntity.h:260
CompareFirstOfPointerPair
constexpr struct CompareFirstOfPointerPair_t CompareFirstOfPointerPair
std::make_pair
T make_pair(T...args)
ChronoEntity::eRMSTime
double eRMSTime() const
r.m.s Elapsed Time
Definition: ChronoEntity.h:275
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
std::scientific
T scientific(T...args)
ChronoEntity::uMeanTime
double uMeanTime() const
average User Time
Definition: ChronoEntity.h:255
std::map::size
T size(T...args)
std::vector
STL class.
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
ChronoEntity::eMaximalTime
double eMaximalTime() const
maximal measurement for elapsed time
Definition: ChronoEntity.h:224
ChronoEntity::nOfMeasurements
unsigned long nOfMeasurements() const
number of chrono measurements
Definition: ChronoEntity.h:194
std::sort
T sort(T...args)
std::transform
T transform(T...args)
ChronoEntity::uMaximalTime
double uMaximalTime() const
maximal measurement for user time
Definition: ChronoEntity.h:214
std::setprecision
T setprecision(T...args)
ana.i
list i
Definition: ana.py:128
ChronoEntity::eTotalTime
double eTotalTime() const
total Elapsed time
Definition: ChronoEntity.h:239
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector::reserve
T reserve(T...args)
ChronoStatSvc::m_chronoEntities
ChronoMap m_chronoEntities
chrono part
Definition: ChronoStatSvc.h:146

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

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

See also
  IChronoStatSvc

Definition at line 444 of file ChronoStatSvc.cpp.

446 {
447 auto theIter=m_statEntities.find(statTag);
448
449 StatEntity * theStat=nullptr ;
450 // if new entity, specify the number of events to be skipped
451 if (theIter==m_statEntities.end()){
452 // new stat entity
453 StatEntity& theSe = m_statEntities[ statTag ];
454 theStat=& theSe;
455 theStat->setnEntriesBeforeReset(m_numberOfSkippedEventsForMemStat);
456 }
457 else
458 {
459 //existing stat entity
460 theStat=&theIter->second;
461 }
462
463 theStat->addFlag ( statFlag ) ;
464 }
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:167
std::map::end
T end(T...args)
ChronoStatSvc::m_numberOfSkippedEventsForMemStat
long m_numberOfSkippedEventsForMemStat
Definition: ChronoStatSvc.h:164
StatEntity::setnEntriesBeforeReset
void setnEntriesBeforeReset(unsigned long nEntriesBeforeReset)
DR specify number of entry before reset.
Definition: StatEntity.cpp:219
StatEntity::addFlag
unsigned long addFlag(const double Flag)
add a flag
Definition: StatEntity.h:412
std::map::find
T find(T...args)
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:64

const StatEntity * ChronoStatSvc::stat | ( | const IChronoStatSvc::StatTag & | t | ) | const
| override 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 495 of file ChronoStatSvc.cpp.

496 {
497 auto it = m_statEntities.find ( t ) ;
498 return m_statEntities.end() != it ? &(it->second) : nullptr;
499 }
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:167
std::map::end
T end(T...args)
std::map::find
T find(T...args)

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

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

See also
  IChronoStatSvc

Definition at line 469 of file ChronoStatSvc.cpp.

470 {
471 MsgStream log ( msgSvc() , statTag ) ;
472 log << (MSG::Level) m_statPrintLevel << m_statEntities[ statTag ] << endmsg;
473 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
ChronoStatSvc::m_statEntities
StatMap m_statEntities
stat part
Definition: ChronoStatSvc.h:167
Gaudi.Configuration.log
tuple log
Definition: Configuration.py:13
MSG::Level
Level
Definition: IMessageSvc.h:15
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
ChronoStatSvc::m_statPrintLevel
MSG::Level m_statPrintLevel
Definition: ChronoStatSvc.h:171
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

## Member Data Documentation

bool ChronoStatSvc::m_chronoCoutFlag
| private

flag for destination of the the final table

Definition at line 153 of file ChronoStatSvc.h.

ChronoMap ChronoStatSvc::m_chronoEntities
| private

chrono part

Definition at line 146 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_chronoOrderFlag
| private

flag for formattion the final statistic table

Definition at line 155 of file ChronoStatSvc.h.

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

Definition at line 149 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_chronoTableFlag
| private

flag for printing the final table

Definition at line 151 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_format1
| private

format for regular statistical printout rows

Definition at line 186 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_format2
| private

format for "efficiency" statistical printout rows

Definition at line 188 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_header
| private

the header row

Definition at line 184 of file ChronoStatSvc.h.

int ChronoStatSvc::m_intChronoPrintLevel
| private

level of info printing

Definition at line 148 of file ChronoStatSvc.h.

int ChronoStatSvc::m_intStatPrintLevel
| private

level of info printing

Definition at line 170 of file ChronoStatSvc.h.

long ChronoStatSvc::m_numberOfSkippedEventsForMemStat
| private

Definition at line 164 of file ChronoStatSvc.h.

std::ofstream ChronoStatSvc::m_ofd
| private

Definition at line 195 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_perEventFile
| private

Definition at line 194 of file ChronoStatSvc.h.

TimeMap ChronoStatSvc::m_perEvtTime
| private

Definition at line 193 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printEllapsedTime
| private

flag for printing Ellapsed quantities

Definition at line 161 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printSystemTime
| private

flag for printing System quantities

Definition at line 159 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printUserTime
| private

flag for printing User quantities

Definition at line 157 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statCoutFlag
| private

flag for destination of the t he final table

Definition at line 175 of file ChronoStatSvc.h.

StatMap ChronoStatSvc::m_statEntities
| private

stat part

Definition at line 167 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statOrderFlag
| private

flag for formattion the final statistic table

Definition at line 177 of file ChronoStatSvc.h.

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

Definition at line 171 of file ChronoStatSvc.h.

StringProperty ChronoStatSvc::m_statsOutFileName
| private

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

Definition at line 181 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statTableFlag
| private

flag for printing the final table

Definition at line 173 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_useEffFormat = true
| private

flag to use the special "efficiency" format

Definition at line 190 of file ChronoStatSvc.h.

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

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