The Gaudi Framework
master (9f3f8895)
Toggle main menu visibility
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
>
13
#include <
GaudiKernel/IChronoStatSvc.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
37
SmartIF<IChronoStatSvc>
&
chronoSvc
() {
return
m_chronoSvc
; }
38
SmartIF<IChronoStatSvc>
m_chronoSvc
;
39
};
40
41
DECLARE_COMPONENT
(
ChronoAuditor
)
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
}
Auditor.h
IChronoStatSvc.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
ChronoAuditor
Monitors the cpu time usage of each algorithm.
Definition
ChronoAuditor.cpp:21
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
ChronoAuditor::chronoSvc
SmartIF< IChronoStatSvc > & chronoSvc()
Definition
ChronoAuditor.cpp:37
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::before
void before(std::string const &evt, std::string const &caller, EventContext const &) override
Default (catch-all) "before" Auditor hook.
Definition
ChronoAuditor.cpp:54
ChronoAuditor::initialize
StatusCode initialize() override
Definition
ChronoAuditor.cpp:43
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition
CommonMessaging.h:109
EventContext
This class represents an entry point to all the event specific data.
Definition
EventContext.h:35
Gaudi::Auditor
Base class from which all concrete auditor classes should be derived.
Definition
Auditor.h:33
Gaudi::Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition
Auditor.h:59
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition
SmartIF.h:28
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
GaudiAud
src
ChronoAuditor.cpp
Generated on
for The Gaudi Framework by
1.17.0