The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
ChronoAuditor.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11
12#include <Gaudi/Auditor.h>
14
22public:
23 using Auditor::Auditor;
24
25 StatusCode initialize() override;
26
27private:
29 void before( std::string const& evt, std::string const& caller, EventContext const& ) override;
30
32 void after( std::string const& evt, std::string const& caller, EventContext const&, const StatusCode& sc ) override;
33
35 std::string i_id( std::string const& evt, std::string_view caller ) { return std::string{ caller } + ":" + evt; }
36
39};
40
42
44 return Auditor::initialize().andThen( [&]() -> StatusCode {
45 m_chronoSvc = serviceLocator()->service( "ChronoStatSvc" );
46 if ( !m_chronoSvc.get() ) {
47 error() << "Cannot get ChronoStatSvc" << endmsg;
49 }
51 } );
52}
53
54void ChronoAuditor::before( std::string const& evt, std::string const& caller, EventContext const& ) {
55 chronoSvc()->chronoStart( i_id( evt, caller ) );
56}
57
58void ChronoAuditor::after( std::string const& evt, std::string const& caller, EventContext const&, const StatusCode& ) {
59 chronoSvc()->chronoStop( i_id( evt, caller ) );
60}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
Monitors the cpu time usage of each algorithm.
void after(std::string const &evt, std::string const &caller, EventContext const &, const StatusCode &sc) override
Default (catch-all) "after" Auditor hook.
SmartIF< IChronoStatSvc > & chronoSvc()
SmartIF< IChronoStatSvc > m_chronoSvc
std::string i_id(std::string const &evt, std::string_view caller)
Compute the id string to be used for the chrono entity.
void before(std::string const &evt, std::string const &caller, EventContext const &) override
Default (catch-all) "before" Auditor hook.
StatusCode initialize() override
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class represents an entry point to all the event specific data.
Base class from which all concrete auditor classes should be derived.
Definition Auditor.h:33
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition Auditor.h:59
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100