Go to the documentation of this file.
16 #include <fmt/format.h>
18 #include <type_traits>
19 #include <unordered_map>
29 return base_class::initialize().
andThen( [&]() {
32 m_incSvc->addListener(
this, IncidentType::BeginEvent );
33 m_incSvc->addListener(
this, IncidentType::EndEvent );
36 debug() <<
"no IncidentSvc, I cannot measure overall event processing time" <<
endmsg;
75 if ( IncidentType::BeginEvent == i.
type() ) {
77 }
else if ( IncidentType::EndEvent == i.
type() ) {
85 info() <<
"-------------------------------------------------------------------" <<
endmsg;
86 info() <<
"Algorithm | exec (ms) | count | total (s)" <<
endmsg;
87 info() <<
"-------------------------------------------------------------------" <<
endmsg;
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() )
96 std::sort(
begin( offsets ),
end( offsets ), [](
auto& a,
auto& b ) {
return a.second < b.second; } );
97 for (
const auto& [
name, offset] : offsets ) {
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() )
105 info() <<
"-------------------------------------------------------------------" <<
endmsg;
108 m_incSvc->removeListener(
this, IncidentType::BeginEvent );
109 m_incSvc->removeListener(
this, IncidentType::EndEvent );
112 return base_class::finalize();
StatusCode finalize() override
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
std::unordered_map< std::string, std::size_t > m_offsets
void before(StandardEventType evt, INamedInterface *alg) override
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
void before(StandardEventType, INamedInterface *) override
The following methods are meant to be implemented by the child class...
std::vector< stats_t > m_stats
std::uint16_t m_currentDepth
clock_t::time_point started
stats_t & stats(INamedInterface *alg)
void after(StandardEventType evt, INamedInterface *alg, const StatusCode &) override
const std::string & name() const override
void after(StandardEventType, INamedInterface *, const StatusCode &) override
AttribStringParser::Iterator begin(const AttribStringParser &parser)
void handle(const Incident &i) override
SmartIF< IIncidentSvc > m_incSvc
clock_t::duration total_time
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Base class used to extend a class implementing other interfaces.
#define DECLARE_COMPONENT(type)
std::vector< std::uint16_t > m_depths
const std::string & type() const
Access to the incident type.
std::conditional_t< std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock, std::chrono::steady_clock > clock_t
CommonMessaging base_class
StatusCode initialize() override
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.