18 #include "boost/assign/list_of.hpp"
20 #include "google/heap-profiler.h"
21 #include "google/heap-checker.h"
22 #include "google/profiler.h"
99 return ( dynamic_cast<GaudiSequencer*>(i) != NULL ||
100 dynamic_cast<Sequencer*>(i) != NULL );
119 const std::string& name )
const
121 std::ostringstream t;
122 t << name <<
"-" <<
type;
123 if ( type ==
"Execute" ) t <<
"-Event" <<
m_nEvts;
187 std::ostringstream t;
200 <<
"Starting Auditor for " << s <<
":" << type
208 <<
"Auditor already running. Cannot be started for " << s
218 std::ostringstream t;
234 std::ostringstream t;
309 , m_log ( msgSvc() , name )
312 , m_sampleEventCount( 0 )
313 , m_inFullAudit ( false )
317 const std::vector<std::string> tmp =
318 boost::assign::list_of
329 "List of phases to activate the Auditoring during" );
331 "List of component names to disable the auditing for" );
334 "The frequence to audit events. -1 means all events" );
336 "If true, instead of individually auditing components, the full event (or events) will be audited in one go" );
338 "The number of events to include in a full event audit, if enabled" );
340 "Number of events to skip before activating the auditing" );
342 "If true, auditing will be skipped for Sequencer objects." );
375 HeapProfilerStart(s.c_str());
382 HeapProfilerDump(s.c_str());
386 const char * profile = GetHeapProfile();
436 const char * HEAPCHECK = getenv(
"HEAPCHECK");
440 <<
"Environment variable HEAPCHECK must be set to 'local'"
444 if ( std::string(HEAPCHECK) !=
"local" )
447 <<
"Environment variable HEAPCHECK is set to " << HEAPCHECK
448 <<
" Partial Program Heap Checking is disabled"
462 m_checker =
new HeapLeakChecker(s.c_str());
518 ProfilerStart((s+
".prof").c_str());
const std::string BeginEvent
Processing of a new event has started.
StatusCode finalize()
Finalize the auditor base.
HeapLeakChecker * m_checker
void beforeBeginRun(INamedInterface *i)
Definition of the MsgStream class used to transmit messages.
std::string m_startedBy
Name of the component we are currently auditing.
HeapChecker(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
void beforeReinitialize(INamedInterface *i)
void stopAudit()
stop a full event audit
StatusCode service(const std::string &name, T *&svc, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
bool m_printProfilesToLog
virtual const std::string & name() const
Retrieve the name of the instance.
const std::string & type() const
Access to the incident type.
StandardEventType
Defines the standard (= used by the framework) auditable event types.
virtual void google_before(const std::string &s)=0
Start the google tool.
virtual ~AuditorBase()
Destructor.
bool m_audit
Internal flag to say if auditing is enabled or not for the current event.
void before(CustomEventTypeRef type, const std::string &s)
Audit the start of a custom "event" for callers that do not implement INamedInterface.
void startAudit()
Start a full event audit.
const CustomEventType & CustomEventTypeRef
Used in function calls for optimization purposes.
unsigned long long m_nSampleEvents
Number of events to include in a full event audit.
virtual bool alreadyRunning()=0
check if we are already running the tool
StatusCode initialize()
Initialize the auditor base.
bool m_inFullAudit
Internal flag to indicate if we are current in a full event audit.
bool isFailure() const
Test for a status code of FAILURE.
unsigned long long m_sampleEventCount
Internal count of the number of events currently processed during an audit.
#define DECLARE_COMPONENT(type)
int m_freq
The frequency to audit events. -1 means all events.
void before(CustomEventTypeRef type, INamedInterface *i)
Audit the start of a custom "event".
virtual const std::string & name() const =0
Retrieve the name of the instance.
bool alreadyRunning()
check if we are already running the tool
StatusCode initialize()
Initialize the auditor base.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
void google_after(const std::string &)
stop the google tool
void after(CustomEventTypeRef type, const std::string &s, const StatusCode &)
Audit the end of a custom "event" for callers that do not implement INamedInterface.
void afterExecute(INamedInterface *i, const StatusCode &s)
unsigned long long m_nEvts
Number of events processed.
bool isValid() const
Allow for check if smart pointer is valid.
void after(CustomEventTypeRef type, INamedInterface *i, const StatusCode &sc)
Audit the end of a custom "event".
void beforeExecute(INamedInterface *i)
void google_before(const std::string &s)
Start the google tool.
This class is used for returning status codes from appropriate routines.
void google_after(const std::string &s)
stop the google tool
Base class used to extend a class implementing other interfaces.
std::vector< std::string > m_list
Any component in this list will be audited. If empty, all will be done.
Auditor using the Google Heap Checker.
void afterBeginRun(INamedInterface *i)
bool m_fullEventAudit
Flag to indicate if full event auditing is enabled or not.
void google_before(const std::string &s)
Start the google tool.
void google_after(const std::string &s)
stop the google tool
bool alreadyRunning()
check if we are already running the tool
HeapProfiler(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SmartIF< ISvcLocator > & serviceLocator() const
The standard service locator.
void afterFinalize(INamedInterface *i)
void afterReinitialize(INamedInterface *i)
void afterInitialize(INamedInterface *i)
std::vector< std::string > m_when
When to audit the algorithms.
void beforeEndRun(INamedInterface *i)
IInterface compliant class extending IInterface with the name() method.
void beforeInitialize(INamedInterface *i)
bool isPhaseEnabled(const CustomEventTypeRef &type) const
Check if auditing is enabled for the current processing phase.
void beforeFinalize(INamedInterface *i)
Base class for all Incidents (computing events).
void before(StandardEventType type, INamedInterface *i)
The following methods are meant to be implemented by the child class...
void handle(const Incident &incident)
Implement the handle method for the Incident service.
void google_before(const std::string &s)
Start the google tool.
MsgStream m_log
Messaging object.
void before(StandardEventType type, const std::string &s)
Audit the start of a standard "event" for callers that do not implement INamedInterface.
void after(StandardEventType type, INamedInterface *i, const StatusCode &sc)
Audit the end of a standard "event".
CPUProfiler(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< std::string > m_veto
Veto list. Any component in this list will not be audited.
AuditorBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
void afterEndRun(INamedInterface *i)
unsigned long long m_eventsToSkip
Number of events to skip before auditing.
Base for Google Auditors.
virtual void google_after(const std::string &s)=0
stop the google tool
bool alreadyRunning()
check if we are already running the tool
Auditor using the Google CPU Profiler.
bool m_skipSequencers
Boolean indicating if sequencers should be skipped or not.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
void after(StandardEventType type, const std::string &s, const StatusCode &sc)
Audit the end of a standard "event" for callers that do not implement INamedInterface.
bool isComponentEnabled(const std::string &name) const
Check if auditing is enabled for the given component.
Auditor based on the Google Heap Profiler.
std::string getDumpName(const CustomEventTypeRef &type, const std::string &name) const
bool isSequencer(INamedInterface *i) const
Check if the component in question is a GaudiSequencer or a Sequencer.