src
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/one/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
namespace
callgrind
{
38
class
Profiler
:
public
edm::one::EDAnalyzer
<> {
39
public
:
40
explicit
Profiler
(
const
edm::ParameterSet
&);
41
~
Profiler
()
override
;
42
43
private
:
44
void
beginJob
()
override
;
45
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
;
46
void
endJob()
override
;
47
48
// ----------member data ---------------------------
49
int
m_firstEvent
;
50
int
m_lastEvent
;
51
int
m_action
;
52
int
m_evtCount
;
53
};
54
}
// namespace callgrind
55
using namespace
callgrind
;
56
//
57
// constants, enums and typedefs
58
//
59
60
//
61
// static data member definitions
62
//
63
64
//
65
// constructors and destructor
66
//
67
Profiler::Profiler(
const
edm::ParameterSet
&
parameters
) {
68
//now do what ever initialization is needed
69
m_firstEvent =
parameters
.getParameter<
int
>(
"firstEvent"
);
70
m_lastEvent =
parameters
.getParameter<
int
>(
"lastEvent"
);
71
m_action =
parameters
.getParameter<
int
>(
"action"
);
72
m_evtCount = 0;
73
}
74
75
Profiler::~Profiler() {
76
// do anything here that needs to be done at desctruction time
77
// (e.g. close files, deallocate resources etc.)
78
}
79
80
//
81
// member functions
82
//
83
84
// ------------ method called to for each event ------------
85
#pragma GCC diagnostic push
86
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
87
void
Profiler::analyze
(
const
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
88
m_evtCount++;
89
if
(m_evtCount >= m_firstEvent && (m_evtCount <= m_lastEvent || m_lastEvent == -1)) {
90
switch
(m_action) {
91
case
0:
92
CALLGRIND_STOP_INSTRUMENTATION;
93
cout
<<
"Stop Instr"
<< endl;
94
break
;
95
case
1:
96
CALLGRIND_START_INSTRUMENTATION;
97
CALLGRIND_DUMP_STATS;
98
cout
<<
"Start Instr"
<< endl;
99
break
;
100
case
2:
101
CALLGRIND_DUMP_STATS;
102
cout
<<
"Dump stat"
<< endl;
103
break
;
104
}
105
}
106
}
107
#pragma GCC diagnostic pop
108
109
// ------------ method called once each job just before starting event loop ------------
110
void
Profiler::beginJob
() {}
111
112
// ------------ method called once each job just after ending the event loop ------------
113
void
Profiler::endJob() {}
114
115
//define this as a plug-in
116
DEFINE_FWK_MODULE
(
Profiler
);
Event.h
std
Definition:
JetResolutionObject.h:76
BeamSpotPI::parameters
parameters
Definition:
BeamSpotPayloadInspectorHelper.h:33
Frameworkfwd.h
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
bk::beginJob
void beginJob()
Definition:
Breakpoints.cc:14
ParameterSet.h
callgrind::Profiler::m_lastEvent
int m_lastEvent
Definition:
CallgrindAnalyzer.cc:50
iEvent
int iEvent
Definition:
GenABIO.cc:224
callgrind::Profiler::m_action
int m_action
Definition:
CallgrindAnalyzer.cc:51
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
edm::EventSetup
Definition:
EventSetup.h:56
callgrind::Profiler::m_firstEvent
int m_firstEvent
Definition:
CallgrindAnalyzer.cc:49
callgrind::Profiler::m_evtCount
int m_evtCount
Definition:
CallgrindAnalyzer.cc:52
EDAnalyzer.h
edm::ParameterSet
Definition:
ParameterSet.h:47
callgrind::Profiler
Definition:
CallgrindAnalyzer.cc:38
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
edm::Event
Definition:
Event.h:73
MakerMacros.h
edm::one::EDAnalyzer
Definition:
EDAnalyzer.h:30
callgrind
Definition:
CallgrindAnalyzer.cc:37
Generated for CMSSW Reference Manual by
1.8.14