| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

MemStatAuditor.cpp
Go to the documentation of this file.
1 #ifdef __ICC
2 // disable icc warning #654: overloaded virtual function "B::Y" is only partially overridden in class "C"
3 // TODO: there is only a partial overload of IAuditor::before and IAuditor::after
4 #pragma warning( disable : 654 )
5 #endif
6
7 #include "GaudiKernel/IChronoStatSvc.h"
8 #include "GaudiKernel/MsgStream.h"
9
10 #include "GaudiKernel/Stat.h"
11
13 #include "MemStatAuditor.h"
14 #include "ProcStats.h"
15
16 DECLARE_COMPONENT( MemStatAuditor )
17
18 MemStatAuditor::MemStatAuditor( const std::string& name, ISvcLocator* pSvcLocator ) : MemoryAuditor( name, pSvcLocator )
19 {
20 }
21
22 StatusCode MemStatAuditor::initialize()
23 {
24 StatusCode sc = CommonAuditor::initialize();
25 if ( UNLIKELY( sc.isFailure() ) ) return sc;
26
27 m_stat = serviceLocator()->service( "ChronoStatSvc" );
28 if ( UNLIKELY( !m_stat.get() ) ) {
29 error() << "Cannot get ChronoStatSvc" << endmsg;
30 return StatusCode::FAILURE;
31 }
32 return StatusCode::SUCCESS;
33 }
34
35 void MemStatAuditor::i_before( CustomEventTypeRef /*evt*/, const std::string& /*caller*/ )
36 {
37 // It's not interesting to monitor the memory usage before the methods.
38 }
39
40 void MemStatAuditor::i_printinfo( const std::string& msg, CustomEventTypeRef evt, const std::string& caller )
41 {
42 // cannot be exactly 0
43 double deltaVSize = 0.00001;
44
45 procInfo pInfo;
46 if ( getProcInfo( pInfo ) ) {
47
48 if ( pInfo.vsize > 0 ) {
49 if ( m_vSize > 0 ) {
50 deltaVSize = pInfo.vsize - m_vSize;
51 }
52 // store the current VSize to be able to monitor the increment
53 m_vSize = pInfo.vsize;
54 }
55
56 info() << msg << " " << caller << " " << evt << " \tvirtual size = " << pInfo.vsize << " MB"
57 << " \tresident set size = " << pInfo.rss << " MB"
58 << " deltaVsize = " << deltaVSize << " MB" << endmsg;
59 }
60 // fill the stat for every call, not just when there is a change
61 // only monitor the increment in VSize
62 // Stat stv(statSvc(), caller + ":VMemUsage", pInfo.vsize);
63 // Stat str(statSvc(), caller + ":RMemUsage", pInfo.rss);
64 Stat sts( statSvc(), caller + ":VMem", deltaVSize );
65 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
StatusCode::SUCCESS
Definition: StatusCode.h:29
CommonMessagingBase::msg
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:121
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
MemStatAuditor
Just a minor modification of MemoryAuditor to allow the output memory statistics table to be printed...
Definition: MemStatAuditor.h:15
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
MsgStream.h
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
Stat
Small wrapper class for easy manipulation with generic counters and IStatSvc&ICounterSvc interface...
Definition: Stat.h:46
std
STL namespace.
MemStatAuditor::initialize
StatusCode initialize() override
Definition: MemStatAuditor.cpp:22
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:61
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:33
std::string
STL class.
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
procInfo::rss
double rss
Definition: ProcStats.h:39
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Auditor.cpp:206
MemStatAuditor::m_vSize
double m_vSize
vsize of the previous call to printinfo
Definition: MemStatAuditor.h:33
MemStatAuditor::m_stat
SmartIF< IChronoStatSvc > m_stat
Definition: MemStatAuditor.h:30
MemoryAuditor::getProcInfo
static bool getProcInfo(procInfo &info)
Get the process informations.
Definition: MemoryAuditor.h:28
ProcStats.h
MemStatAuditor::i_before
void i_before(CustomEventTypeRef evt, const std::string &caller) override
Re-implement i_before to avoid monitoring the memory usage before a function.
Definition: MemStatAuditor.cpp:35
Stat.h
IChronoStatSvc.h
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.cpp:70
MemoryAuditor
Monitors the memory use of each algorithm.
Definition: MemoryAuditor.h:11
StatusCode::FAILURE
Definition: StatusCode.h:29
procInfo::vsize
double vsize
Definition: ProcStats.h:38
MemStatAuditor::statSvc
SmartIF< IChronoStatSvc > & statSvc()
Definition: MemStatAuditor.h:29
procInfo
Definition: ProcStats.h:17
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
IOTest.evt
evt
Definition: IOTest.py:96
MemStatAuditor::i_printinfo
void i_printinfo(const std::string &msg, CustomEventTypeRef evt, const std::string &caller) override
Report the memory usage.
Definition: MemStatAuditor.cpp:40
MemStatAuditor.h