| The Gaudi Framework v32r1 (f65d50dc)

CallgrindProfile.cpp
Go to the documentation of this file.
1 // Include files
2 #include <iostream>
3
4 // local
5 #include "CallgrindProfile.h"
6 #include "local_callgrind.h"
7
8 //-----------------------------------------------------------------------------
9 // Implementation file for class : CallgrindProfile
10 //
11 // 2014-08-22 : Ben Couturier
12 //-----------------------------------------------------------------------------
13
14 // Declaration of the Algorithm Factory
15 DECLARE_COMPONENT( CallgrindProfile )
16
17 //=============================================================================
18 // Main execution
19 //=============================================================================
20 StatusCode CallgrindProfile::execute() {
21
22 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg;
23
24 // Increase event number
25 ++m_eventNumber;
26
27 if ( m_eventNumber == m_nStartFromEvent ) {
28 m_profiling = true;
29 warning() << "Starting Callgrind profile at event " << m_eventNumber << endmsg;
30 CALLGRIND_START_INSTRUMENTATION;
31 }
32
33 if ( m_eventNumber == m_nZeroAtEvent ) {
34 warning() << "Setting Callgrind counters to zero at event " << m_eventNumber << endmsg;
35 CALLGRIND_ZERO_STATS;
36 }
37
38 if ( m_eventNumber == m_nStopAtEvent ) {
39 m_profiling = false;
40 warning() << "Stopping Callgrind profile at event " << m_eventNumber << endmsg;
41 CALLGRIND_STOP_INSTRUMENTATION;
42 }
43
44 if ( m_eventNumber == m_nDumpAtEvent ) {
45 warning() << "Dumping Callgrind counters to zero at event " << m_eventNumber << endmsg;
46
47 if ( m_dumpName == "" ) {
48 CALLGRIND_DUMP_STATS;
49 } else {
50 CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
51 }
52 m_dumpDone = true;
53 }
54
55 return StatusCode::SUCCESS;
56 }
57
58 //=============================================================================
59 // Finalize
60 //=============================================================================
61 StatusCode CallgrindProfile::finalize() {
62
63 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg;
64
65 if ( !m_dumpDone ) {
66 if ( m_dumpName == "" ) {
67 CALLGRIND_DUMP_STATS;
68 } else {
69 CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
70 }
71 }
72
73 return Algorithm::finalize(); // must be called after all other actions
74 }
75
76 //=============================================================================
CALLGRIND_START_INSTRUMENTATION
#define CALLGRIND_START_INSTRUMENTATION
Definition: local_callgrind.h:106
CallgrindProfile::m_dumpDone
bool m_dumpDone
Definition: CallgrindProfile.h:37
MSG::DEBUG
Definition: IMessageSvc.h:15
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
CallgrindProfile::m_dumpName
Gaudi::Property< std::string > m_dumpName
Definition: CallgrindProfile.h:33
CALLGRIND_ZERO_STATS
#define CALLGRIND_ZERO_STATS
Definition: local_callgrind.h:94
CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:138
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:186
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
CallgrindProfile.h
CALLGRIND_DUMP_STATS
#define CALLGRIND_DUMP_STATS
Definition: local_callgrind.h:84
CALLGRIND_DUMP_STATS_AT
#define CALLGRIND_DUMP_STATS_AT(pos_str)
Definition: local_callgrind.h:90
CallgrindProfile::finalize
StatusCode finalize() override
Algorithm finalization.
Definition: CallgrindProfile.cpp:61
CallgrindProfile
Algorithm to enable/disable the profiling by Callgrind at given events.
Definition: CallgrindProfile.h:15
local_callgrind.h
CALLGRIND_STOP_INSTRUMENTATION
#define CALLGRIND_STOP_INSTRUMENTATION
Definition: local_callgrind.h:116
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192