ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
PerfMon::CallGraphBuilderSvc Class Reference

#include <CallGraphBuilderSvc.h>

Inheritance diagram for PerfMon::CallGraphBuilderSvc:
Collaboration diagram for PerfMon::CallGraphBuilderSvc:

Public Types

typedef unsigned long NodeId_t
 

Public Member Functions

 CallGraphBuilderSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters: More...
 
virtual ~CallGraphBuilderSvc ()
 Destructor: More...
 
StatusCode initialize ()
 Gaudi Service Implementation. More...
 
StatusCode finalize ()
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 
void openNode (const std::string &nodeName)
 open a new node in the call graph tree More...
 
void closeNode (const std::string &nodeName)
 close an existing node in the call graph tree More...
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Inline methods:
More...
 

Private Types

typedef boost::adjacency_list CallGraph_t
 

Private Member Functions

 CallGraphBuilderSvc ()
 Default constructor: More...
 

Private Attributes

std::recursive_mutex m_mutex
 Mutex protecting the following members. More...
 
GaudiUtils::HashMap< std::string, NodeId_t > m_nameToId ATLAS_THREAD_SAFE
 Method-name-to-UUID. More...
 
GaudiUtils::HashMap< NodeId_t, std::string > m_idToName ATLAS_THREAD_SAFE
 UUID-to-Method-name. More...
 
std::stack< NodeId_t > m_stack ATLAS_THREAD_SAFE
 stack of method names (in fact their uuid) More...
 
CallGraph_t m_graph ATLAS_THREAD_SAFE
 the callgraph More...
 

Static Private Attributes

static NodeId_t m_uuid ATLAS_THREAD_SAFE
 a "unique identifier" for node names More...
 

Friends

class SvcFactory< CallGraphBuilderSvc >
 

Detailed Description

Definition at line 40 of file CallGraphBuilderSvc.h.

Member Typedef Documentation

◆ CallGraph_t

typedef boost::adjacency_list PerfMon::CallGraphBuilderSvc::CallGraph_t
private

Definition at line 110 of file CallGraphBuilderSvc.h.

◆ NodeId_t

Definition at line 52 of file CallGraphBuilderSvc.h.

Constructor & Destructor Documentation

◆ CallGraphBuilderSvc() [1/2]

PerfMon::CallGraphBuilderSvc::CallGraphBuilderSvc ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Constructor with parameters:

Definition at line 39 of file CallGraphBuilderSvc.cxx.

40  :
41  AthService( name, pSvcLocator )
42 {
43  //
44  // Property declaration
45  //
46  //declareProperty( "Property", m_nProperty, "descr" );
47 
48  // install the root of the nodes for our callgraph modelisation
49  // (would be so simple with a boost::bimap ... (boost 1.35 ?)
50  m_nameToId[s_rootName] = s_rootId;
51  m_idToName[s_rootId ] = s_rootName;
52 }

◆ ~CallGraphBuilderSvc()

PerfMon::CallGraphBuilderSvc::~CallGraphBuilderSvc ( )
virtual

Destructor:

Definition at line 56 of file CallGraphBuilderSvc.cxx.

57 {
58  msg() << MSG::DEBUG << "Calling destructor" << endmsg;
59 }

◆ CallGraphBuilderSvc() [2/2]

PerfMon::CallGraphBuilderSvc::CallGraphBuilderSvc ( )
private

Default constructor:

Member Function Documentation

◆ closeNode()

void PerfMon::CallGraphBuilderSvc::closeNode ( const std::string &  nodeName)
virtual

close an existing node in the call graph tree

Implements ICallGraphBuilderSvc.

Definition at line 139 of file CallGraphBuilderSvc.cxx.

140 {
141  std::scoped_lock lock(m_mutex);
142 
143  const NodeId_t nodeId = m_nameToId[nodeName];
144  //boost::add_edge( nodeId, 1, m_graph);
145  msg() << MSG::VERBOSE
146  << "<-- [" << nodeName << "] = " << nodeId
147  << endmsg;
148 
149  if ( !m_stack.empty() ) {
150  m_stack.pop();
151  }
152  return;
153 }

◆ finalize()

StatusCode PerfMon::CallGraphBuilderSvc::finalize ( )

Definition at line 85 of file CallGraphBuilderSvc.cxx.

86 {
87  msg() << MSG::INFO
88  << "Finalizing " << name() << "..."
89  << endmsg;
90 
91  return StatusCode::SUCCESS;
92 }

◆ initialize()

StatusCode PerfMon::CallGraphBuilderSvc::initialize ( )

Gaudi Service Implementation.

Definition at line 63 of file CallGraphBuilderSvc.cxx.

64 {
65  // initialize MsgStream
66  msg().setLevel( m_outputLevel.value() );
67 
68  msg() << MSG::INFO
69  << "Initializing " << name() << "..."
70  << endmsg;
71 
72  msg() << MSG::DEBUG << "Initializing base class..." << endmsg;
73  if ( AthService::initialize().isFailure() ) {
74  msg() << MSG::ERROR
75  << "Could not initialize base class !!"
76  << endmsg;
77  return StatusCode::FAILURE;
78  } else {
79  msg() << MSG::VERBOSE << "Base class initialized" << endmsg;
80  }
81 
82  return StatusCode::SUCCESS;
83 }

◆ interfaceID()

const InterfaceID & PerfMon::CallGraphBuilderSvc::interfaceID ( )
inlinestatic

Inline methods:

Definition at line 121 of file CallGraphBuilderSvc.h.

122 {
124 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ openNode()

void PerfMon::CallGraphBuilderSvc::openNode ( const std::string &  nodeName)
virtual

open a new node in the call graph tree

Implements ICallGraphBuilderSvc.

Definition at line 117 of file CallGraphBuilderSvc.cxx.

118 {
119  std::scoped_lock lock(m_mutex);
120 
121  if ( m_nameToId.find( nodeName ) == m_nameToId.end() ) {
122  m_nameToId[nodeName] = ++m_uuid;
123  m_idToName[m_uuid ] = nodeName;
124  }
125 
126  const NodeId_t nodeId = m_nameToId[nodeName];
127  const NodeId_t parentId = m_stack.empty() ? 0 : m_stack.top();
128  m_stack.push( nodeId );
129 
130  boost::add_edge( parentId, nodeId, m_graph );
131 
132  msg() << MSG::VERBOSE
133  << "--> [" << nodeName << "] = " << nodeId << "\t"
134  << "(parent = " << m_idToName[parentId] << ")"
135  << endmsg;
136  return;
137 }

◆ queryInterface()

StatusCode PerfMon::CallGraphBuilderSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
virtual

Definition at line 100 of file CallGraphBuilderSvc.cxx.

102 {
103  if ( ICallGraphBuilderSvc::interfaceID().versionMatch(riid) ) {
104  *ppvInterface = dynamic_cast<ICallGraphBuilderSvc*>(this);
105  } else {
106  // Interface is not directly available : try out a base class
107  return AthService::queryInterface(riid, ppvInterface);
108  }
109  addRef();
110  return StatusCode::SUCCESS;
111 }

Friends And Related Function Documentation

◆ SvcFactory< CallGraphBuilderSvc >

friend class SvcFactory< CallGraphBuilderSvc >
friend

Definition at line 121 of file CallGraphBuilderSvc.h.

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/5]

NodeId_t m_uuid PerfMon::CallGraphBuilderSvc::ATLAS_THREAD_SAFE
staticprivate

a "unique identifier" for node names

Definition at line 100 of file CallGraphBuilderSvc.h.

◆ ATLAS_THREAD_SAFE [2/5]

GaudiUtils::HashMap<std::string, NodeId_t> m_nameToId PerfMon::CallGraphBuilderSvc::ATLAS_THREAD_SAFE
private

Method-name-to-UUID.

Definition at line 103 of file CallGraphBuilderSvc.h.

◆ ATLAS_THREAD_SAFE [3/5]

GaudiUtils::HashMap<NodeId_t, std::string> m_idToName PerfMon::CallGraphBuilderSvc::ATLAS_THREAD_SAFE
private

UUID-to-Method-name.

Definition at line 105 of file CallGraphBuilderSvc.h.

◆ ATLAS_THREAD_SAFE [4/5]

std::stack<NodeId_t> m_stack PerfMon::CallGraphBuilderSvc::ATLAS_THREAD_SAFE
private

stack of method names (in fact their uuid)

Definition at line 108 of file CallGraphBuilderSvc.h.

◆ ATLAS_THREAD_SAFE [5/5]

CallGraph_t m_graph PerfMon::CallGraphBuilderSvc::ATLAS_THREAD_SAFE
private

the callgraph

Definition at line 112 of file CallGraphBuilderSvc.h.

◆ m_mutex

std::recursive_mutex PerfMon::CallGraphBuilderSvc::m_mutex
private

Mutex protecting the following members.

Definition at line 97 of file CallGraphBuilderSvc.h.


The documentation for this class was generated from the following files:
AthService::AthService
AthService()
PerfMon::CallGraphBuilderSvc::m_mutex
std::recursive_mutex m_mutex
Mutex protecting the following members.
Definition: CallGraphBuilderSvc.h:97
initialize
void initialize()
Definition: run_EoverP.cxx:894
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ICallGraphBuilderSvc::interfaceID
static const InterfaceID & interfaceID()
Definition: ICallGraphBuilderSvc.h:60
PerfMon::CallGraphBuilderSvc::NodeId_t
unsigned long NodeId_t
Definition: CallGraphBuilderSvc.h:52
xAOD::parentId
@ parentId
Definition: TrackingPrimitives.h:516
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Service >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
ICallGraphBuilderSvc
Definition: ICallGraphBuilderSvc.h:23