PerfTools
Callgrind
plugins
CallgrindAnalyzer.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: Profiler
4
// Class: Profiler
5
//
13
//
14
// Original Author: Andrea Rizzi
15
// Created: Thu Jan 18 10:34:18 CET 2007
16
//
17
//
18
19
// system include files
20
#include <memory>
21
22
// user include files
23
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
24
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
25
26
#include "
FWCore/Framework/interface/Event.h
"
27
#include "
FWCore/Framework/interface/MakerMacros.h
"
28
29
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
30
31
#include "valgrind/callgrind.h"
32
//
33
// class declaration
34
//
35
#include <iostream>
36
using namespace
std
;
37
class
Profiler
:
public
edm::EDAnalyzer
{
38
public
:
39
explicit
Profiler
(
const
edm::ParameterSet
&);
40
~
Profiler
()
override
;
41
42
private
:
43
void
beginJob
()
override
;
44
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
;
45
void
endJob()
override
;
46
47
// ----------member data ---------------------------
48
int
m_firstEvent
;
49
int
m_lastEvent
;
50
int
m_action
;
51
int
m_evtCount
;
52
};
53
54
//
55
// constants, enums and typedefs
56
//
57
58
//
59
// static data member definitions
60
//
61
62
//
63
// constructors and destructor
64
//
65
Profiler::Profiler
(
const
edm::ParameterSet
&
parameters
) {
66
//now do what ever initialization is needed
67
m_firstEvent =
parameters
.getParameter<
int
>(
"firstEvent"
);
68
m_lastEvent =
parameters
.getParameter<
int
>(
"lastEvent"
);
69
m_action =
parameters
.getParameter<
int
>(
"action"
);
70
m_evtCount = 0;
71
}
72
73
Profiler::~Profiler
() {
74
// do anything here that needs to be done at desctruction time
75
// (e.g. close files, deallocate resources etc.)
76
}
77
78
//
79
// member functions
80
//
81
82
// ------------ method called to for each event ------------
83
#pragma GCC diagnostic push
84
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
85
void
Profiler::analyze
(
const
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
86
m_evtCount++;
87
if
(m_evtCount >= m_firstEvent && (m_evtCount <= m_lastEvent || m_lastEvent == -1)) {
88
switch
(m_action) {
89
case
0:
90
CALLGRIND_STOP_INSTRUMENTATION;
91
cout
<<
"Stop Instr"
<< endl;
92
break
;
93
case
1:
94
CALLGRIND_START_INSTRUMENTATION;
95
CALLGRIND_DUMP_STATS;
96
cout
<<
"Start Instr"
<< endl;
97
break
;
98
case
2:
99
CALLGRIND_DUMP_STATS;
100
cout
<<
"Dump stat"
<< endl;
101
break
;
102
}
103
}
104
}
105
#pragma GCC diagnostic pop
106
107
// ------------ method called once each job just before starting event loop ------------
108
void
Profiler::beginJob
() {}
109
110
// ------------ method called once each job just after ending the event loop ------------
111
void
Profiler::endJob
() {}
112
113
//define this as a plug-in
114
DEFINE_FWK_MODULE
(
Profiler
);
bk::beginJob
void beginJob()
Definition:
Breakpoints.cc:14
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
Profiler::m_firstEvent
int m_firstEvent
Definition:
CallgrindAnalyzer.cc:48
EDAnalyzer.h
edm::EDAnalyzer
Definition:
EDAnalyzer.h:29
parameters
parameters
Definition:
BeamSpot_PayloadInspector.cc:14
Profiler::endJob
void endJob() override
Definition:
CallgrindAnalyzer.cc:111
MakerMacros.h
Profiler::~Profiler
~Profiler() override
Definition:
CallgrindAnalyzer.cc:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
Profiler
Definition:
CallgrindAnalyzer.cc:37
Profiler::m_lastEvent
int m_lastEvent
Definition:
CallgrindAnalyzer.cc:49
edm::ParameterSet
Definition:
ParameterSet.h:36
Event.h
iEvent
int iEvent
Definition:
GenABIO.cc:224
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition:
EventSetup.h:57
Profiler::m_action
int m_action
Definition:
CallgrindAnalyzer.cc:50
std
Definition:
JetResolutionObject.h:76
Frameworkfwd.h
Profiler::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition:
CallgrindAnalyzer.cc:85
Profiler::Profiler
Profiler(const edm::ParameterSet &)
Definition:
CallgrindAnalyzer.cc:65
Profiler::m_evtCount
int m_evtCount
Definition:
CallgrindAnalyzer.cc:51
ParameterSet.h
edm::Event
Definition:
Event.h:73
Profiler::beginJob
void beginJob() override
Definition:
CallgrindAnalyzer.cc:108
Generated for CMSSW Reference Manual by
1.8.16