The Gaudi Framework  v33r0 (d5ea422b)
ChronoAuditor.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 // ChronoAuditor:
12 // An auditor that monitors time
13 
14 #ifdef __ICC
15 // disable icc warning #654: overloaded virtual function "B::Y" is only partially overridden in class "C"
16 // TODO: there is only a partial overload of IAuditor::before and IAuditor::after
17 # pragma warning( disable : 654 )
18 #endif
19 
20 #include "ChronoAuditor.h"
21 
23 
24 StatusCode ChronoAuditor::initialize() {
26  if ( UNLIKELY( sc.isFailure() ) ) return sc;
27 
28  m_chronoSvc = serviceLocator()->service( "ChronoStatSvc" );
29  if ( UNLIKELY( !m_chronoSvc.get() ) ) {
30  error() << "Cannot get ChronoStatSvc" << endmsg;
31  return StatusCode::FAILURE;
32  }
33  return StatusCode::SUCCESS;
34 }
35 
36 void ChronoAuditor::i_before( CustomEventTypeRef evt, const std::string& caller ) {
37  chronoSvc()->chronoStart( i_id( evt, caller ) );
38 }
39 
40 void ChronoAuditor::i_after( CustomEventTypeRef evt, const std::string& caller, const StatusCode& ) {
41  chronoSvc()->chronoStop( i_id( evt, caller ) );
42 }
#define UNLIKELY(x)
Definition: Kernel.h:106
SmartIF< IChronoStatSvc > & chronoSvc()
Definition: ChronoAuditor.h:40
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
STL class.
#define DECLARE_COMPONENT(type)
void i_before(CustomEventTypeRef evt, const std::string &caller) override
Default (catch-all) "before" Auditor hook.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
void i_after(CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc) override
Default (catch-all) "after" Auditor hook.
Monitors the cpu time usage of each algorithm.
Definition: ChronoAuditor.h:24
constexpr static const auto FAILURE
Definition: StatusCode.h:97
virtual StatusCode initialize()
Definition: Auditor.cpp:74
bool isFailure() const
Definition: StatusCode.h:141
std::string i_id(CustomEventTypeRef evt, const std::string &caller)
Compute the id string to be used for the chrono entity.
Definition: ChronoAuditor.h:38
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202