| The Gaudi Framework v28r2p1 (f1a77ff4)

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