| The Gaudi Framework v29r1 (5cd95fa2)

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

- File List
- File Members

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_ALGORITHM_FACTORY( CallgrindProfile )
16
17 //=============================================================================
18 // Initialization
19 //=============================================================================
20 StatusCode CallgrindProfile::initialize()
21 {
22 StatusCode sc = GaudiAlgorithm::initialize(); // must be executed first
23 if ( sc.isFailure() ) return sc; // error printed already by GaudiAlgorithm
24
25 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Initialize" << endmsg;
26 return StatusCode::SUCCESS;
27 }
28
29 //=============================================================================
30 // Main execution
31 //=============================================================================
32 StatusCode CallgrindProfile::execute()
33 {
34
35 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg;
36
37 // Increase event number
38 m_eventNumber += 1;
39
40 if ( m_eventNumber == m_nStartFromEvent ) {
41 m_profiling = true;
42 warning() << "Starting Callgrind profile at event " << m_eventNumber << endmsg;
43 CALLGRIND_START_INSTRUMENTATION;
44 }
45
46 if ( m_eventNumber == m_nZeroAtEvent ) {
47 warning() << "Setting Callgrind counters to zero at event " << m_eventNumber << endmsg;
48 CALLGRIND_ZERO_STATS;
49 }
50
51 if ( m_eventNumber == m_nStopAtEvent ) {
52 m_profiling = false;
53 warning() << "Stopping Callgrind profile at event " << m_eventNumber << endmsg;
54 CALLGRIND_STOP_INSTRUMENTATION;
55 }
56
57 if ( m_eventNumber == m_nDumpAtEvent ) {
58 warning() << "Dumping Callgrind counters to zero at event " << m_eventNumber << endmsg;
59
60 if ( m_dumpName == "" ) {
61 CALLGRIND_DUMP_STATS;
62 } else {
63 CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
64 }
65 m_dumpDone = true;
66 }
67
68 return StatusCode::SUCCESS;
69 }
70
71 //=============================================================================
72 // Finalize
73 //=============================================================================
74 StatusCode CallgrindProfile::finalize()
75 {
76
77 if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg;
78
79 if ( !m_dumpDone ) {
80 if ( m_dumpName == "" ) {
81 CALLGRIND_DUMP_STATS;
82 } else {
83 CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
84 }
85 }
86
87 return GaudiAlgorithm::finalize(); // must be called after all other actions
88 }
89
90 //=============================================================================
CallgrindProfile::m_profiling
bool m_profiling
Definition: CallgrindProfile.h:40
StatusCode::SUCCESS
Definition: StatusCode.h:31
CALLGRIND_START_INSTRUMENTATION
#define CALLGRIND_START_INSTRUMENTATION
Definition: local_callgrind.h:106
CallgrindProfile::m_eventNumber
int m_eventNumber
Definition: CallgrindProfile.h:39
CallgrindProfile::m_dumpDone
bool m_dumpDone
Definition: CallgrindProfile.h:41
GaudiAlgorithm::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiAlgorithm.cpp:43
MSG::DEBUG
Definition: IMessageSvc.h:16
CallgrindProfile::m_nDumpAtEvent
Gaudi::Property< int > m_nDumpAtEvent
Definition: CallgrindProfile.h:31
CallgrindProfile::m_nStartFromEvent
Gaudi::Property< int > m_nStartFromEvent
Definition: CallgrindProfile.h:27
CallgrindProfile::m_dumpName
Gaudi::Property< std::string > m_dumpName
Definition: CallgrindProfile.h:37
CALLGRIND_ZERO_STATS
#define CALLGRIND_ZERO_STATS
Definition: local_callgrind.h:94
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
CallgrindProfile::m_nZeroAtEvent
Gaudi::Property< int > m_nZeroAtEvent
Definition: CallgrindProfile.h:34
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
GaudiAlgorithm::finalize
StatusCode finalize() override
standard finalization method
Definition: GaudiAlgorithm.cpp:59
DECLARE_ALGORITHM_FACTORY
#define DECLARE_ALGORITHM_FACTORY(x)
Definition: Algorithm.h:631
CallgrindProfile.h
CallgrindProfile::execute
StatusCode execute() override
Algorithm execution.
Definition: CallgrindProfile.cpp:32
CALLGRIND_DUMP_STATS
#define CALLGRIND_DUMP_STATS
Definition: local_callgrind.h:84
CallgrindProfile::finalize
StatusCode finalize() override
Algorithm finalization.
Definition: CallgrindProfile.cpp:74
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
CallgrindProfile
Algorithm to enable/disable the profiling by Callgrind at given events.
Definition: CallgrindProfile.h:15
local_callgrind.h
CallgrindProfile::m_nStopAtEvent
Gaudi::Property< int > m_nStopAtEvent
Definition: CallgrindProfile.h:28
CALLGRIND_STOP_INSTRUMENTATION
#define CALLGRIND_STOP_INSTRUMENTATION
Definition: local_callgrind.h:116
CommonMessagingBase::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:124
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
CALLGRIND_DUMP_STATS_AT
#define CALLGRIND_DUMP_STATS_AT(pos_str)
Definition: local_callgrind.h:90