The Gaudi Framework
v26r1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
CallgrindProfile.cpp
Go to the documentation of this file.
1
// Include files
2
#include <iostream>
3
4
// from Gaudi
5
#include "GaudiKernel/AlgFactory.h"
6
7
// local
8
#include "
local_callgrind.h
"
9
#include "
CallgrindProfile.h
"
10
11
//-----------------------------------------------------------------------------
12
// Implementation file for class : CallgrindProfile
13
//
14
// 2014-08-22 : Ben Couturier
15
//-----------------------------------------------------------------------------
16
17
// Declaration of the Algorithm Factory
18
DECLARE_ALGORITHM_FACTORY
(
CallgrindProfile
)
19
20
21
//=============================================================================
22
// Standard constructor, initializes variables
23
//=============================================================================
24
CallgrindProfile
::
CallgrindProfile
( const
std
::
string
& name,
25
ISvcLocator
* pSvcLocator)
26
:
GaudiAlgorithm
( name , pSvcLocator )
27
{
28
29
declareProperty(
"StartFromEventN"
, m_nStartFromEvent = 1,
30
"After what event we start profiling. "
31
);
32
33
declareProperty(
"StopAtEventN"
, m_nStopAtEvent = 0,
34
"After what event we stop profiling. "
35
"If 0 than we also profile finalization stage. Default = 0."
36
);
37
38
declareProperty(
"DumpAtEventN"
, m_nDumpAtEvent = 0,
39
"After what event we stop profiling. "
40
"If 0 than we also profile finalization stage. Default = 0."
41
);
42
43
declareProperty(
"ZeroAtEventN"
, m_nZeroAtEvent = 0,
44
"After what event we stop profiling. "
45
"If 0 than we also profile finalization stage. Default = 0."
46
);
47
declareProperty(
"DumpName"
, m_dumpName =
""
,
48
"Label for the callgrind dump "
49
);
50
51
// Internal counter for event numbers
52
m_eventNumber = 0;
53
54
// Current state
55
m_profiling =
false
;
56
57
// Flag to indicate whether the callgrind was done
58
m_dumpDone =
false
;
59
60
}
61
//=============================================================================
62
// Destructor
63
//=============================================================================
64
CallgrindProfile::~CallgrindProfile
() {}
65
66
//=============================================================================
67
// Initialization
68
//=============================================================================
69
StatusCode
CallgrindProfile::initialize
() {
70
StatusCode
sc
=
GaudiAlgorithm::initialize
();
// must be executed first
71
if
( sc.
isFailure
() )
return
sc;
// error printed already by GaudiAlgorithm
72
73
if
(
msgLevel
(
MSG::DEBUG
) )
debug
() <<
"==> Initialize"
<<
endmsg
;
74
return
StatusCode::SUCCESS
;
75
}
76
77
//=============================================================================
78
// Main execution
79
//=============================================================================
80
StatusCode
CallgrindProfile::execute
() {
81
82
if
(
msgLevel
(
MSG::DEBUG
) )
debug
() <<
"==> Execute"
<<
endmsg
;
83
84
// Increase event number
85
m_eventNumber
+= 1;
86
87
if
(
m_eventNumber
==
m_nStartFromEvent
)
88
{
89
m_profiling
=
true
;
90
warning
() <<
"Starting Callgrind profile at event "
91
<<
m_eventNumber
<<
endmsg
;
92
CALLGRIND_START_INSTRUMENTATION
;
93
}
94
95
if
(
m_eventNumber
==
m_nZeroAtEvent
)
96
{
97
warning
() <<
"Setting Callgrind counters to zero at event "
98
<<
m_eventNumber
<<
endmsg
;
99
CALLGRIND_ZERO_STATS
;
100
}
101
102
if
(
m_eventNumber
==
m_nStopAtEvent
)
103
{
104
m_profiling
=
false
;
105
warning
() <<
"Stopping Callgrind profile at event "
106
<<
m_eventNumber
<<
endmsg
;
107
CALLGRIND_STOP_INSTRUMENTATION
;
108
}
109
110
if
(
m_eventNumber
==
m_nDumpAtEvent
)
111
{
112
warning
() <<
"Dumping Callgrind counters to zero at event "
113
<<
m_eventNumber
<<
endmsg
;
114
115
if
(
m_dumpName
==
""
)
116
{
117
CALLGRIND_DUMP_STATS
;
118
}
119
else
120
{
121
CALLGRIND_DUMP_STATS_AT
(
m_dumpName
.c_str());
122
}
123
m_dumpDone
=
true
;
124
}
125
126
return
StatusCode::SUCCESS
;
127
}
128
129
//=============================================================================
130
// Finalize
131
//=============================================================================
132
StatusCode
CallgrindProfile::finalize
() {
133
134
if
(
msgLevel
(
MSG::DEBUG
) )
debug
() <<
"==> Finalize"
<<
endmsg
;
135
136
if
(!
m_dumpDone
)
137
{
138
if
(
m_dumpName
==
""
)
139
{
140
CALLGRIND_DUMP_STATS
;
141
}
142
else
143
{
144
CALLGRIND_DUMP_STATS_AT
(
m_dumpName
.c_str());
145
}
146
}
147
148
return
GaudiAlgorithm::finalize
();
// must be called after all other actions
149
}
150
151
//=============================================================================
GaudiProfiling
src
component
valgrind
CallgrindProfile.cpp
Generated on Mon Feb 16 2015 11:56:57 for The Gaudi Framework by
1.8.2