The Gaudi Framework  master (37c0b60a)
CallgrindProfile.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 // Include files
12 #include <iostream>
13 
14 // local
15 #include "CallgrindProfile.h"
16 #include "local_callgrind.h"
17 
18 //-----------------------------------------------------------------------------
19 // Implementation file for class : CallgrindProfile
20 //
21 // 2014-08-22 : Ben Couturier
22 //-----------------------------------------------------------------------------
23 
24 // Declaration of the Algorithm Factory
26 
27 //=============================================================================
28 // Main execution
29 //=============================================================================
31 
32  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg;
33 
34  // Increase event number
35  ++m_eventNumber;
36 
37  if ( m_eventNumber == m_nStartFromEvent ) {
38  m_profiling = true;
39  warning() << "Starting Callgrind profile at event " << m_eventNumber << endmsg;
41  }
42 
43  if ( m_eventNumber == m_nZeroAtEvent ) {
44  warning() << "Setting Callgrind counters to zero at event " << m_eventNumber << endmsg;
46  }
47 
48  if ( m_eventNumber == m_nStopAtEvent ) {
49  m_profiling = false;
50  warning() << "Stopping Callgrind profile at event " << m_eventNumber << endmsg;
52  }
53 
54  if ( m_eventNumber == m_nDumpAtEvent ) {
55  warning() << "Dumping Callgrind counters to zero at event " << m_eventNumber << endmsg;
56 
57  if ( m_dumpName == "" ) {
59  } else {
60  CALLGRIND_DUMP_STATS_AT( m_dumpName.value().c_str() );
61  }
62  m_dumpDone = true;
63  }
64 
65  return StatusCode::SUCCESS;
66 }
67 
68 //=============================================================================
69 // Finalize
70 //=============================================================================
72 
73  if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Finalize" << endmsg;
74 
75  if ( !m_dumpDone ) {
76  if ( m_dumpName == "" ) {
78  } else {
80  }
81  }
82 
83  return Algorithm::finalize(); // must be called after all other actions
84 }
85 
86 //=============================================================================
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
CALLGRIND_START_INSTRUMENTATION
#define CALLGRIND_START_INSTRUMENTATION
Definition: local_callgrind.h:106
CallgrindProfile
Definition: CallgrindProfile.h:25
CallgrindProfile::m_dumpName
Gaudi::Property< std::string > m_dumpName
Definition: CallgrindProfile.h:43
CallgrindProfile.h
CALLGRIND_DUMP_STATS
#define CALLGRIND_DUMP_STATS
Definition: local_callgrind.h:84
CALLGRIND_STOP_INSTRUMENTATION
#define CALLGRIND_STOP_INSTRUMENTATION
Definition: local_callgrind.h:116
CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
StatusCode
Definition: StatusCode.h:65
GaudiPython.Pythonizations.execute
execute
Definition: Pythonizations.py:578
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:237
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
CALLGRIND_DUMP_STATS_AT
#define CALLGRIND_DUMP_STATS_AT(pos_str)
Definition: local_callgrind.h:90
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:184
CALLGRIND_ZERO_STATS
#define CALLGRIND_ZERO_STATS
Definition: local_callgrind.h:94
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
local_callgrind.h
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
CallgrindProfile::m_dumpDone
bool m_dumpDone
Definition: CallgrindProfile.h:47
CallgrindProfile::finalize
StatusCode finalize() override
Algorithm finalization.
Definition: CallgrindProfile.cpp:71