All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
16 
17 //=============================================================================
18 // Initialization
19 //=============================================================================
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 //=============================================================================
32 
33  if ( msgLevel(MSG::DEBUG) ) debug() << "==> Execute" << endmsg;
34 
35  // Increase event number
36  m_eventNumber += 1;
37 
39  {
40  m_profiling = true;
41  warning() << "Starting Callgrind profile at event "
42  << m_eventNumber << endmsg;
44  }
45 
47  {
48  warning() << "Setting Callgrind counters to zero at event "
49  << m_eventNumber << endmsg;
51  }
52 
54  {
55  m_profiling = false;
56  warning() << "Stopping Callgrind profile at event "
57  << m_eventNumber << endmsg;
59  }
60 
62  {
63  warning() << "Dumping Callgrind counters to zero at event "
64  << m_eventNumber << endmsg;
65 
66  if (m_dumpName == "")
67  {
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 //=============================================================================
84 
85  if ( msgLevel(MSG::DEBUG) ) debug() << "==> Finalize" << endmsg;
86 
87  if (!m_dumpDone)
88  {
89  if (m_dumpName == "")
90  {
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 //=============================================================================
#define CALLGRIND_START_INSTRUMENTATION
StatusCode initialize() override
standard initialization method
Gaudi::Property< int > m_nDumpAtEvent
Gaudi::Property< int > m_nStartFromEvent
Gaudi::Property< std::string > m_dumpName
#define CALLGRIND_ZERO_STATS
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
Gaudi::Property< int > m_nZeroAtEvent
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode finalize() override
standard finalization method
#define DECLARE_ALGORITHM_FACTORY(x)
Definition: Algorithm.h:620
#define CALLGRIND_DUMP_STATS_AT(pos_str)
StatusCode execute() override
Algorithm execution.
#define CALLGRIND_DUMP_STATS
StatusCode finalize() override
Algorithm finalization.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Algorithm to enable/disable the profiling by Callgrind at given events.
Gaudi::Property< int > m_nStopAtEvent
#define CALLGRIND_STOP_INSTRUMENTATION
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244