Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 "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  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg;
23 
24  // Increase event number
25  ++m_eventNumber;
26 
27  if ( m_eventNumber == m_nStartFromEvent ) {
28  m_profiling = true;
29  warning() << "Starting Callgrind profile at event " << m_eventNumber << endmsg;
31  }
32 
33  if ( m_eventNumber == m_nZeroAtEvent ) {
34  warning() << "Setting Callgrind counters to zero at event " << m_eventNumber << endmsg;
36  }
37 
38  if ( m_eventNumber == m_nStopAtEvent ) {
39  m_profiling = false;
40  warning() << "Stopping Callgrind profile at event " << m_eventNumber << endmsg;
42  }
43 
44  if ( m_eventNumber == m_nDumpAtEvent ) {
45  warning() << "Dumping Callgrind counters to zero at event " << m_eventNumber << endmsg;
46 
47  if ( m_dumpName == "" ) {
49  } else {
50  CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
51  }
52  m_dumpDone = true;
53  }
54 
55  return StatusCode::SUCCESS;
56 }
57 
58 //=============================================================================
59 // Finalize
60 //=============================================================================
62 
63  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg;
64 
65  if ( !m_dumpDone ) {
66  if ( m_dumpName == "" ) {
68  } else {
69  CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
70  }
71  }
72 
73  return Algorithm::finalize(); // must be called after all other actions
74 }
75 
76 //=============================================================================
#define CALLGRIND_START_INSTRUMENTATION
StatusCode execute() override final
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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:50
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:186
#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:192
#define CALLGRIND_DUMP_STATS_AT(pos_str)
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)