The Gaudi Framework  master (594c33fa)
AlgTimingAuditor Struct Referencefinal
Inheritance diagram for AlgTimingAuditor:
Collaboration diagram for AlgTimingAuditor:

Classes

struct  stats_t
 

Public Types

using clock_t = std::conditional_t< std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock, std::chrono::steady_clock >
 
- Public Types inherited from extends< Auditor, 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 Auditor
using Factory = Gaudi::PluginService::Factory< IAuditor *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
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
 
void before (StandardEventType evt, INamedInterface *alg) override
 
void after (StandardEventType evt, INamedInterface *alg, const StatusCode &) override
 
void handle (const Incident &i) override
 
StatusCode finalize () override
 
stats_tstats (INamedInterface *alg)
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
- Public Member Functions inherited from extends< Auditor, 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::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Auditor
 Auditor (std::string name, ISvcLocator *svcloc)
 Constructor. More...
 
 Auditor (const Auditor &a)=delete
 
Auditoroperator= (const Auditor &rhs)=delete
 
StatusCode sysInitialize () override
 Initialization method invoked by the framework. More...
 
StatusCode sysFinalize () override
 Finalization method invoked by the framework. More...
 
void before (StandardEventType, INamedInterface *) override
 The following methods are meant to be implemented by the child class... More...
 
void before (StandardEventType, const std::string &) override
 
void before (CustomEventTypeRef, INamedInterface *) override
 
void before (CustomEventTypeRef, const std::string &) override
 
void after (StandardEventType, INamedInterface *, const StatusCode &) override
 
void after (StandardEventType, const std::string &, const StatusCode &) override
 
void after (CustomEventTypeRef, INamedInterface *, const StatusCode &) override
 
void after (CustomEventTypeRef, const std::string &, const StatusCode &) override
 
void beforeInitialize (INamedInterface *) override
 
void afterInitialize (INamedInterface *) override
 
void beforeReinitialize (INamedInterface *) override
 
void afterReinitialize (INamedInterface *) override
 
void beforeExecute (INamedInterface *) override
 
void afterExecute (INamedInterface *, const StatusCode &) override
 
void beforeFinalize (INamedInterface *) override
 
void afterFinalize (INamedInterface *) override
 
const std::stringname () const override
 
bool isEnabled () const override
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator. More...
 
template<class T >
StatusCode service (std::string_view name, T *&svc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T = IService>
SmartIF< T > service (std::string_view name, bool createIf=false) const
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (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::PropertyBasedeclareProperty (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::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view 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 (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
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...
 

Public Attributes

SmartIF< IIncidentSvcm_incSvc
 
std::unordered_map< std::string, std::size_tm_offsets
 
std::vector< std::uint16_tm_depths
 
std::vector< stats_tm_stats
 
stats_t m_eventLoopStats
 
std::uint16_t m_currentDepth { 0 }
 

Additional Inherited Members

- Protected Member Functions inherited from CommonMessaging< implements< IAuditor, IProperty > >
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...
 

Detailed Description

Definition at line 22 of file AlgTimingAuditor.cpp.

Member Typedef Documentation

◆ clock_t

using AlgTimingAuditor::clock_t = std::conditional_t<std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock, std::chrono::steady_clock>

Definition at line 115 of file AlgTimingAuditor.cpp.

Member Function Documentation

◆ after() [1/5]

void Auditor::after
override

Definition at line 77 of file Auditor.cpp.

139 {}

◆ after() [2/5]

void Auditor::after
override

Definition at line 76 of file Auditor.cpp.

138 {}

◆ after() [3/5]

void AlgTimingAuditor::after ( StandardEventType  evt,
INamedInterface alg,
const StatusCode  
)
inlineoverride

Definition at line 58 of file AlgTimingAuditor.cpp.

58  {
59  if ( !alg ) return;
60  switch ( evt ) {
61  case Initialize:
63  break;
64 
65  case Execute:
66  stats( alg ).stop();
67  break;
68 
69  default:
70  break;
71  }
72  }

◆ after() [4/5]

void Auditor::after
override

Definition at line 74 of file Auditor.cpp.

136 {}

◆ after() [5/5]

void Auditor::after
override

Definition at line 73 of file Auditor.cpp.

112  {
113  switch ( evt ) {
114  case Initialize:
115  afterInitialize( obj );
116  break;
117  case ReInitialize:
118  afterReinitialize( obj );
119  break;
120  case Execute:
121  afterExecute( obj, sc );
122  break;
123  case Finalize:
124  afterFinalize( obj );
125  break;
126  case Start:
127  break;
128  case Stop:
129  break;
130  case ReStart:
131  break;
132  default:
133  break; // do nothing
134  }
135 }

◆ before() [1/5]

void Auditor::before
override

Definition at line 71 of file Auditor.cpp.

109 {}

◆ before() [2/5]

void Auditor::before
override

Definition at line 70 of file Auditor.cpp.

108 {}

◆ before() [3/5]

void AlgTimingAuditor::before ( StandardEventType  evt,
INamedInterface alg 
)
inlineoverride

Definition at line 41 of file AlgTimingAuditor.cpp.

41  {
42  if ( !alg ) return;
43  switch ( evt ) {
44  case Initialize:
45  stats( alg ); // this implicitly adds the algorithm to the list of known ones
47  break;
48 
49  case Execute:
50  stats( alg ).start();
51  break;
52 
53  default:
54  break;
55  }
56  }

◆ before() [4/5]

void Auditor::before
override

Definition at line 68 of file Auditor.cpp.

106 {}

◆ before() [5/5]

void Auditor::before
override

The following methods are meant to be implemented by the child class...

Definition at line 67 of file Auditor.cpp.

82  {
83  switch ( evt ) {
84  case Initialize:
85  beforeInitialize( obj );
86  break;
87  case ReInitialize:
88  beforeReinitialize( obj );
89  break;
90  case Execute:
91  beforeExecute( obj );
92  break;
93  case Finalize:
94  beforeFinalize( obj );
95  break;
96  case Start:
97  break;
98  case Stop:
99  break;
100  case ReStart:
101  break;
102  default:
103  break; // do nothing
104  }
105 }

◆ finalize()

StatusCode AlgTimingAuditor::finalize ( )
inlineoverridevirtual

Reimplemented from Auditor.

Definition at line 82 of file AlgTimingAuditor.cpp.

82  {
85  info() << "-------------------------------------------------------------------" << endmsg;
86  info() << "Algorithm | exec (ms) | count | total (s)" << endmsg;
87  info() << "-------------------------------------------------------------------" << endmsg;
88  if ( m_incSvc ) {
89  const auto count = m_eventLoopStats.count;
90  const auto total_time = m_eventLoopStats.total_time;
91  info() << fmt::format( "{:<30.30} | {:9.4} | {:9} | {:9.4}", "EVENT LOOP",
92  count ? ms( total_time ).count() / count : 0.f, count, s( total_time ).count() )
93  << endmsg;
94  }
96  std::sort( begin( offsets ), end( offsets ), []( auto& a, auto& b ) { return a.second < b.second; } );
97  for ( const auto& [name, offset] : offsets ) {
98  std::string indented_name = std::string( m_depths[offset], ' ' ) + name;
99  const auto count = m_stats[offset].count;
100  const auto total_time = m_stats[offset].total_time;
101  info() << fmt::format( "{:<30.30} | {:9.4} | {:9} | {:9.4}", indented_name,
102  count ? ms( total_time ).count() / count : 0.f, count, s( total_time ).count() )
103  << endmsg;
104  }
105  info() << "-------------------------------------------------------------------" << endmsg;
106 
107  if ( m_incSvc ) {
108  m_incSvc->removeListener( this, IncidentType::BeginEvent );
109  m_incSvc->removeListener( this, IncidentType::EndEvent );
110  m_incSvc.reset();
111  }
112  return base_class::finalize();
113  }

◆ handle()

void AlgTimingAuditor::handle ( const Incident i)
inlineoverride

Definition at line 74 of file AlgTimingAuditor.cpp.

74  {
75  if ( IncidentType::BeginEvent == i.type() ) {
77  } else if ( IncidentType::EndEvent == i.type() ) {
79  }
80  }

◆ initialize()

StatusCode AlgTimingAuditor::initialize ( )
inlineoverridevirtual

Reimplemented from Auditor.

Definition at line 28 of file AlgTimingAuditor.cpp.

28  {
29  return base_class::initialize().andThen( [&]() {
30  m_incSvc = service( "IncidentSvc" );
31  if ( m_incSvc ) {
32  m_incSvc->addListener( this, IncidentType::BeginEvent );
33  m_incSvc->addListener( this, IncidentType::EndEvent );
35  } else {
36  debug() << "no IncidentSvc, I cannot measure overall event processing time" << endmsg;
37  }
38  } );
39  }

◆ stats()

stats_t& AlgTimingAuditor::stats ( INamedInterface alg)
inline

Definition at line 130 of file AlgTimingAuditor.cpp.

130  {
131  if ( auto it = m_offsets.find( alg->name() ); it != end( m_offsets ) ) {
132  return m_stats[it->second];
133  } else {
135  m_stats.emplace_back();
136  m_offsets[alg->name()] = m_stats.size() - 1;
137  return m_stats.back();
138  }
139  }

Member Data Documentation

◆ m_currentDepth

std::uint16_t AlgTimingAuditor::m_currentDepth { 0 }

Definition at line 147 of file AlgTimingAuditor.cpp.

◆ m_depths

std::vector<std::uint16_t> AlgTimingAuditor::m_depths

Definition at line 144 of file AlgTimingAuditor.cpp.

◆ m_eventLoopStats

stats_t AlgTimingAuditor::m_eventLoopStats

Definition at line 146 of file AlgTimingAuditor.cpp.

◆ m_incSvc

SmartIF<IIncidentSvc> AlgTimingAuditor::m_incSvc

Definition at line 141 of file AlgTimingAuditor.cpp.

◆ m_offsets

std::unordered_map<std::string, std::size_t> AlgTimingAuditor::m_offsets

Definition at line 143 of file AlgTimingAuditor.cpp.

◆ m_stats

std::vector<stats_t> AlgTimingAuditor::m_stats

Definition at line 145 of file AlgTimingAuditor.cpp.


The documentation for this struct was generated from the following file:
IOTest.evt
evt
Definition: IOTest.py:107
Auditor::beforeInitialize
void beforeInitialize(INamedInterface *) override
Definition: Auditor.cpp:141
AlgTimingAuditor::stats_t::start
void start()
Definition: AlgTimingAuditor.cpp:123
std::string
STL class.
AlgTimingAuditor::m_offsets
std::unordered_map< std::string, std::size_t > m_offsets
Definition: AlgTimingAuditor.cpp:143
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector
STL class.
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
std::unordered_map::find
T find(T... args)
std::chrono::duration
Auditor::beforeReinitialize
void beforeReinitialize(INamedInterface *) override
Definition: Auditor.cpp:143
AlgTimingAuditor::m_stats
std::vector< stats_t > m_stats
Definition: AlgTimingAuditor.cpp:145
Auditor::afterExecute
void afterExecute(INamedInterface *, const StatusCode &) override
Definition: Auditor.cpp:146
AlgTimingAuditor::stats_t::count
std::size_t count
Definition: AlgTimingAuditor.cpp:120
AlgTimingAuditor::m_currentDepth
std::uint16_t m_currentDepth
Definition: AlgTimingAuditor.cpp:147
std::sort
T sort(T... args)
AlgTimingAuditor::stats
stats_t & stats(INamedInterface *alg)
Definition: AlgTimingAuditor.cpp:130
Gaudi::Units::ms
constexpr double ms
Definition: SystemOfUnits.h:154
std::vector::push_back
T push_back(T... args)
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:81
Auditor::name
const std::string & name() const override
Definition: Auditor.cpp:192
Auditor::beforeFinalize
void beforeFinalize(INamedInterface *) override
Definition: Auditor.cpp:147
AlgTimingAuditor::stats_t::stop
void stop()
Definition: AlgTimingAuditor.cpp:124
Auditor::afterReinitialize
void afterReinitialize(INamedInterface *) override
Definition: Auditor.cpp:144
CLHEP::begin
double * begin(CLHEP::HepVector &v)
Definition: TupleAlg.cpp:45
AlgTimingAuditor::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition: AlgTimingAuditor.cpp:141
Auditor::afterFinalize
void afterFinalize(INamedInterface *) override
Definition: Auditor.cpp:148
AlgTimingAuditor::stats_t::total_time
clock_t::duration total_time
Definition: AlgTimingAuditor.cpp:119
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
Auditor::afterInitialize
void afterInitialize(INamedInterface *) override
Definition: Auditor.cpp:142
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
Auditor::beforeExecute
void beforeExecute(INamedInterface *) override
Definition: Auditor.cpp:145
std::count
T count(T... args)
AlgTimingAuditor::m_depths
std::vector< std::uint16_t > m_depths
Definition: AlgTimingAuditor.cpp:144
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:48
IOTest.end
end
Definition: IOTest.py:125
AlgTimingAuditor::m_eventLoopStats
stats_t m_eventLoopStats
Definition: AlgTimingAuditor.cpp:146
Auditor::service
StatusCode service(std::string_view name, T *&svc, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
Definition: Auditor.h:109