Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
21 class ChronoAuditor : public Gaudi::Auditor {
22 public:
23  using Auditor::Auditor;
24 
25  StatusCode initialize() override;
26 
27 private:
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 
43 StatusCode ChronoAuditor::initialize() {
44  return Auditor::initialize().andThen( [&]() -> StatusCode {
45  m_chronoSvc = serviceLocator()->service( "ChronoStatSvc" );
46  if ( !m_chronoSvc.get() ) {
47  error() << "Cannot get ChronoStatSvc" << endmsg;
48  return StatusCode::FAILURE;
49  }
50  return StatusCode::SUCCESS;
51  } );
52 }
53 
54 void ChronoAuditor::before( std::string const& evt, std::string const& caller, EventContext const& ) {
55  chronoSvc()->chronoStart( i_id( evt, caller ) );
56 }
57 
58 void ChronoAuditor::after( std::string const& evt, std::string const& caller, EventContext const&, const StatusCode& ) {
59  chronoSvc()->chronoStop( i_id( evt, caller ) );
60 }
IOTest.evt
evt
Definition: IOTest.py:107
ChronoAuditor::m_chronoSvc
SmartIF< IChronoStatSvc > m_chronoSvc
Definition: ChronoAuditor.cpp:38
ChronoAuditor::i_id
std::string i_id(std::string const &evt, std::string_view caller)
Compute the id string to be used for the chrono entity.
Definition: ChronoAuditor.cpp:35
ChronoAuditor::chronoSvc
SmartIF< IChronoStatSvc > & chronoSvc()
Definition: ChronoAuditor.cpp:37
ChronoAuditor::after
void after(std::string const &evt, std::string const &caller, EventContext const &, const StatusCode &sc) override
Default (catch-all) "after" Auditor hook.
Definition: ChronoAuditor.cpp:58
StatusCode
Definition: StatusCode.h:64
SmartIF< IChronoStatSvc >
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:198
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
ChronoAuditor::initialize
StatusCode initialize() override
Definition: ChronoAuditor.cpp:43
IChronoStatSvc.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:45
EventContext
Definition: EventContext.h:34
ChronoAuditor
Definition: ChronoAuditor.cpp:21
ChronoAuditor::before
void before(std::string const &evt, std::string const &caller, EventContext const &) override
Default (catch-all) "before" Auditor hook.
Definition: ChronoAuditor.cpp:54
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
Gaudi::Auditor
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:33
Auditor.h