The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
AlgTimingAuditor Struct Referencefinal
Inheritance diagram for AlgTimingAuditor:
Collaboration diagram for AlgTimingAuditor:

Classes

struct  stats_t
 

Public Types

using clock_t
 
- Public Types inherited from extends< Gaudi::Auditor, IIncidentListener >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- Public Types inherited from Gaudi::Auditor
using Factory = Gaudi::PluginService::Factory<IAuditor*( const std::string&, ISvcLocator* )>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IAuditor, IProperty > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 

Public Member Functions

StatusCode initialize () override
 
void before (std::string const &evt, std::string const &alg, EventContext const &) override
 
void after (std::string const &evt, std::string const &alg, EventContext const &, const StatusCode &) override
 
void handle (const Incident &i) override
 
StatusCode finalize () override
 
stats_tstats (std::string const &alg)
 
- Public Member Functions inherited from extends< Gaudi::Auditor, IIncidentListener >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from Gaudi::Auditor
 Auditor (std::string name, ISvcLocator *svcloc)
 
 Auditor (const Auditor &a)=delete
 
Auditoroperator= (const Auditor &rhs)=delete
 
StatusCode sysInitialize () override
 
StatusCode sysFinalize () override
 
void before (std::string const &, std::string const &, EventContext const &) override
 
void after (std::string const &, std::string const &, EventContext const &, StatusCode const &=StatusCode::SUCCESS) override
 
const std::string & name () const override
 
bool isEnabled () const override
 
SmartIF< ISvcLocator > & serviceLocator () const override
 The standard service locator.
 
template<class T = IService>
SmartIF< T > service (std::string_view name, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAuditor, IProperty > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
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.
 
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.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
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)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Public Attributes

SmartIF< IIncidentSvcm_incSvc
 
std::unordered_map< std::string, std::size_t > m_offsets
 
std::vector< std::uint16_t > m_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.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 

Detailed Description

Definition at line 22 of file AlgTimingAuditor.cpp.

Member Typedef Documentation

◆ clock_t

Initial value:
std::conditional_t<std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock,
std::chrono::steady_clock>

Definition at line 99 of file AlgTimingAuditor.cpp.

Member Function Documentation

◆ after()

void AlgTimingAuditor::after ( std::string const & evt,
std::string const & alg,
EventContext const & ,
const StatusCode &  )
inlineoverride

Definition at line 50 of file AlgTimingAuditor.cpp.

50 {
51 if ( evt == Gaudi::IAuditor::Initialize ) {
53 } else if ( evt == Gaudi::IAuditor::Execute ) {
54 stats( alg ).stop();
55 }
56 }
static const std::string Initialize
Definition IAuditor.h:47
static const std::string Execute
Definition IAuditor.h:51
stats_t & stats(std::string const &alg)
std::uint16_t m_currentDepth

◆ before()

void AlgTimingAuditor::before ( std::string const & evt,
std::string const & alg,
EventContext const &  )
inlineoverride

Definition at line 41 of file AlgTimingAuditor.cpp.

41 {
42 if ( evt == Gaudi::IAuditor::Initialize ) {
43 stats( alg ); // this implicitly adds the algorithm to the list of known ones
45 } else if ( evt == Gaudi::IAuditor::Execute ) {
46 stats( alg ).start();
47 }
48 }

◆ finalize()

StatusCode AlgTimingAuditor::finalize ( )
inlineoverridevirtual

Reimplemented from Gaudi::Auditor.

Definition at line 66 of file AlgTimingAuditor.cpp.

66 {
67 using ms = std::chrono::duration<float, std::milli>;
68 using s = std::chrono::duration<float>;
69 info() << "-------------------------------------------------------------------" << endmsg;
70 info() << "Algorithm | exec (ms) | count | total (s)" << endmsg;
71 info() << "-------------------------------------------------------------------" << endmsg;
72 if ( m_incSvc ) {
73 const auto count = m_eventLoopStats.count;
74 const auto total_time = m_eventLoopStats.total_time;
75 info() << std::format( "{:<30.30} | {:9.4} | {:9} | {:9.4}", "EVENT LOOP",
76 count ? ms( total_time ).count() / count : 0.f, count, s( total_time ).count() )
77 << endmsg;
78 }
79 std::vector<std::pair<std::string, std::size_t>> offsets{ begin( m_offsets ), end( m_offsets ) };
80 std::sort( begin( offsets ), end( offsets ), []( auto& a, auto& b ) { return a.second < b.second; } );
81 for ( const auto& [name, offset] : offsets ) {
82 std::string indented_name = std::string( m_depths[offset], ' ' ) + name;
83 const auto count = m_stats[offset].count;
84 const auto total_time = m_stats[offset].total_time;
85 info() << std::format( "{:<30.30} | {:9.4} | {:9} | {:9.4}", indented_name,
86 count ? ms( total_time ).count() / count : 0.f, count, s( total_time ).count() )
87 << endmsg;
88 }
89 info() << "-------------------------------------------------------------------" << endmsg;
90
91 if ( m_incSvc ) {
92 m_incSvc->removeListener( this, IncidentType::BeginEvent );
93 m_incSvc->removeListener( this, IncidentType::EndEvent );
94 m_incSvc.reset();
95 }
96 return base_class::finalize();
97 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
const std::string & name() const override
Definition Auditor.h:51
constexpr double ms
AttribStringParser::Iterator begin(const AttribStringParser &parser)
std::vector< std::uint16_t > m_depths
std::vector< stats_t > m_stats
SmartIF< IIncidentSvc > m_incSvc
std::unordered_map< std::string, std::size_t > m_offsets

◆ handle()

void AlgTimingAuditor::handle ( const Incident & i)
inlineoverride

Definition at line 58 of file AlgTimingAuditor.cpp.

58 {
59 if ( IncidentType::BeginEvent == i.type() ) {
60 m_eventLoopStats.start();
61 } else if ( IncidentType::EndEvent == i.type() ) {
62 m_eventLoopStats.stop();
63 }
64 }
const std::string & type() const
Access to the incident type.
Definition Incident.h:43

◆ initialize()

StatusCode AlgTimingAuditor::initialize ( )
inlineoverridevirtual

Reimplemented from Gaudi::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 }
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
SmartIF< T > service(std::string_view name, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
Definition Auditor.h:63

◆ stats()

stats_t & AlgTimingAuditor::stats ( std::string const & alg)
inline

Definition at line 114 of file AlgTimingAuditor.cpp.

114 {
115 if ( auto it = m_offsets.find( alg ); it != end( m_offsets ) ) {
116 return m_stats[it->second];
117 } else {
118 m_depths.push_back( m_currentDepth );
119 m_stats.emplace_back();
120 m_offsets[alg] = m_stats.size() - 1;
121 return m_stats.back();
122 }
123 }

Member Data Documentation

◆ m_currentDepth

std::uint16_t AlgTimingAuditor::m_currentDepth { 0 }

Definition at line 131 of file AlgTimingAuditor.cpp.

131{ 0 };

◆ m_depths

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

Definition at line 128 of file AlgTimingAuditor.cpp.

◆ m_eventLoopStats

stats_t AlgTimingAuditor::m_eventLoopStats

Definition at line 130 of file AlgTimingAuditor.cpp.

◆ m_incSvc

SmartIF<IIncidentSvc> AlgTimingAuditor::m_incSvc

Definition at line 125 of file AlgTimingAuditor.cpp.

◆ m_offsets

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

Definition at line 127 of file AlgTimingAuditor.cpp.

◆ m_stats

std::vector<stats_t> AlgTimingAuditor::m_stats

Definition at line 129 of file AlgTimingAuditor.cpp.


The documentation for this struct was generated from the following file: