Go to the documentation of this file.
16 #include <fmt/format.h>
18 #include <type_traits>
19 #include <unordered_map>
26 using Auditor::before;
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;
59 if ( IncidentType::BeginEvent == i.
type() ) {
61 }
else if ( IncidentType::EndEvent == i.
type() ) {
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;
75 info() <<
fmt::format(
"{:<30.30} | {:9.4} | {:9} | {:9.4}",
"EVENT LOOP",
76 count ?
ms( total_time ).count() / count : 0.f, count,
s( total_time ).count() )
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() <<
fmt::format(
"{:<30.30} | {:9.4} | {:9} | {:9.4}", indented_name,
86 count ?
ms( total_time ).count() / count : 0.f, count,
s( total_time ).count() )
89 info() <<
"-------------------------------------------------------------------" <<
endmsg;
92 m_incSvc->removeListener(
this, IncidentType::BeginEvent );
93 m_incSvc->removeListener(
this, IncidentType::EndEvent );
96 return base_class::finalize();
99 using clock_t = std::conditional_t<std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock,
100 std::chrono::steady_clock>;
static const std::string Execute
StatusCode finalize() override
static const std::string Initialize
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 reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
void after(std::string const &evt, std::string const &alg, EventContext const &, const StatusCode &) override
std::vector< stats_t > m_stats
std::uint16_t m_currentDepth
clock_t::time_point started
AttribStringParser::Iterator begin(const AttribStringParser &parser)
stats_t & stats(std::string const &alg)
void handle(const Incident &i) override
SmartIF< IIncidentSvc > m_incSvc
const std::string & name() const override
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.
void before(std::string const &evt, std::string const &alg, EventContext const &) override
#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
SmartIF< T > service(std::string_view name, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
StatusCode initialize() override