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() << 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() )
 
   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() )
 
   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>;
 
 
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
This class represents an entry point to all the event specific data.
const std::string & name() const override
SmartIF< T > service(std::string_view name, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
static const std::string Initialize
static const std::string Execute
Base class for all Incidents (computing events).
const std::string & type() const
Access to the incident type.
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Base class used to extend a class implementing other interfaces.
extends base_class
Typedef to this class.
clock_t::time_point started
clock_t::duration total_time
StatusCode initialize() override
void after(std::string const &evt, std::string const &alg, EventContext const &, const StatusCode &) override
std::vector< std::uint16_t > m_depths
std::vector< stats_t > m_stats
std::conditional_t< std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock, std::chrono::steady_clock > clock_t
void handle(const Incident &i) override
SmartIF< IIncidentSvc > m_incSvc
std::unordered_map< std::string, std::size_t > m_offsets
void before(std::string const &evt, std::string const &alg, EventContext const &) override
stats_t & stats(std::string const &alg)
StatusCode finalize() override
std::uint16_t m_currentDepth