The Gaudi Framework  v30r3 (a5ef0a68)
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
16 
17 //=============================================================================
18 // Main execution
19 //=============================================================================
21 {
22 
23  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg;
24 
25  // Increase event number
26  ++m_eventNumber;
27 
28  if ( m_eventNumber == m_nStartFromEvent ) {
29  m_profiling = true;
30  warning() << "Starting Callgrind profile at event " << m_eventNumber << endmsg;
32  }
33 
34  if ( m_eventNumber == m_nZeroAtEvent ) {
35  warning() << "Setting Callgrind counters to zero at event " << m_eventNumber << endmsg;
37  }
38 
39  if ( m_eventNumber == m_nStopAtEvent ) {
40  m_profiling = false;
41  warning() << "Stopping Callgrind profile at event " << m_eventNumber << endmsg;
43  }
44 
45  if ( m_eventNumber == m_nDumpAtEvent ) {
46  warning() << "Dumping Callgrind counters to zero at event " << m_eventNumber << endmsg;
47 
48  if ( m_dumpName == "" ) {
50  } else {
51  CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
52  }
53  m_dumpDone = true;
54  }
55 
56  return StatusCode::SUCCESS;
57 }
58 
59 //=============================================================================
60 // Finalize
61 //=============================================================================
63 {
64 
65  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg;
66 
67  if ( !m_dumpDone ) {
68  if ( m_dumpName == "" ) {
70  } else {
71  CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
72  }
73  }
74 
75  return Algorithm::finalize(); // must be called after all other actions
76 }
77 
78 //=============================================================================
#define CALLGRIND_START_INSTRUMENTATION
StatusCode execute() override final
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:185
Gaudi::Property< std::string > m_dumpName
#define CALLGRIND_ZERO_STATS
#define DECLARE_COMPONENT(type)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
#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.
#define CALLGRIND_STOP_INSTRUMENTATION
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
#define CALLGRIND_DUMP_STATS_AT(pos_str)
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)