All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ChronoAuditor.cpp
Go to the documentation of this file.
1 // ChronoAuditor:
2 // An auditor that monitors time
3 
4 #ifdef __ICC
5 // disable icc warning #654: overloaded virtual function "B::Y" is only partially overridden in class "C"
6 // TODO: there is only a partial overload of IAuditor::before and IAuditor::after
7 #pragma warning(disable:654)
8 #endif
9 
10 #include "ChronoAuditor.h"
11 
13 
14 ChronoAuditor::ChronoAuditor(const std::string& name, ISvcLocator* pSvcLocator)
15 : CommonAuditor(name, pSvcLocator) {
16 }
17 
19 
22  if (UNLIKELY(sc.isFailure())) return sc;
23 
24  m_chronoSvc = serviceLocator()->service("ChronoStatSvc");
25  if (UNLIKELY(!m_chronoSvc.get())) {
26  MsgStream log(msgSvc(), name());
27  log << MSG::ERROR << "Cannot get ChronoStatSvc" << endmsg;
28  return StatusCode::FAILURE;
29  }
30  return StatusCode::SUCCESS;
31 }
32 
33 void ChronoAuditor::i_before(CustomEventTypeRef evt, const std::string& caller)
34 {
35  chronoSvc()->chronoStart(i_id(evt, caller));
36 }
37 
38 void ChronoAuditor::i_after(CustomEventTypeRef evt, const std::string& caller, const StatusCode&)
39 {
40  chronoSvc()->chronoStop(i_id(evt, caller));
41 }
virtual void i_after(CustomEventTypeRef evt, const std::string &caller, const StatusCode &sc)
Default (catch-all) "after" Auditor hook.
#define UNLIKELY(x)
Definition: Kernel.h:127
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
virtual const std::string & name() const
Retrieve the name of the instance.
Definition: Auditor.cpp:218
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:226
SmartIF< IChronoStatSvc > & chronoSvc()
Definition: ChronoAuditor.h:34
Base class with common functionalities shared by few auditor implementations.
Definition: CommonAuditor.h:5
const CustomEventType & CustomEventTypeRef
Used in function calls for optimization purposes.
Definition: IAuditor.h:41
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode initialize()
SmartIF< IChronoStatSvc > m_chronoSvc
Definition: ChronoAuditor.h:35
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:62
SmartIF< ISvcLocator > & serviceLocator() const
The standard service locator.
Definition: Auditor.cpp:236
Monitors the cpu time usage of each algorithm.
Definition: ChronoAuditor.h:14
virtual ~ChronoAuditor()
virtual StatusCode initialize()
Definition: Auditor.cpp:97
virtual void i_before(CustomEventTypeRef evt, const std::string &caller)
Default (catch-all) "before" Auditor hook.
std::string i_id(CustomEventTypeRef evt, const std::string &caller)
Compute the id string to be used for the chrono entity.
Definition: ChronoAuditor.h:30
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244