CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
31 
32 
33 #include "valgrind/callgrind.h"
34 //
35 // class declaration
36 //
37 #include <iostream>
38 using namespace std;
39 class Profiler : public edm::EDAnalyzer {
40 public:
41  explicit Profiler(const edm::ParameterSet&);
42  ~Profiler();
43 
44 
45 private:
46  virtual void beginJob() override ;
47  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
48  virtual void endJob() override ;
49 
50  // ----------member data ---------------------------
53  int m_action;
55 };
56 
57 //
58 // constants, enums and typedefs
59 //
60 
61 //
62 // static data member definitions
63 //
64 
65 //
66 // constructors and destructor
67 //
69 {
70  //now do what ever initialization is needed
71  m_firstEvent = parameters.getParameter<int>("firstEvent");
72  m_lastEvent = parameters.getParameter<int>("lastEvent");
73  m_action = parameters.getParameter<int>("action");
74  m_evtCount=0;
75 
76 }
77 
78 
80 {
81 
82  // do anything here that needs to be done at desctruction time
83  // (e.g. close files, deallocate resources etc.)
84 
85 }
86 
87 
88 //
89 // member functions
90 //
91 
92 // ------------ method called to for each event ------------
93 #pragma GCC diagnostic push
94 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
95 void
97 {
98 m_evtCount++;
99 if(m_evtCount >= m_firstEvent && (m_evtCount <= m_lastEvent || m_lastEvent == -1))
100  {
101  switch (m_action)
102  {
103  case 0:
104  CALLGRIND_STOP_INSTRUMENTATION;
105  cout << "Stop Instr" << endl;
106  break;
107  case 1:
108  CALLGRIND_START_INSTRUMENTATION;
109  CALLGRIND_DUMP_STATS;
110  cout << "Start Instr" << endl;
111  break;
112  case 2:
113  CALLGRIND_DUMP_STATS;
114  cout << "Dump stat" << endl;
115  break;
116 
117  }
118 
119  }
120 }
121 #pragma GCC diagnostic pop
122 
123 
124 // ------------ method called once each job just before starting event loop ------------
125 void
127 {
128 }
129 
130 // ------------ method called once each job just after ending the event loop ------------
131 void
133 }
134 
135 //define this as a plug-in
T getParameter(std::string const &) const
dictionary parameters
Definition: Parameters.py:2
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:243
virtual void beginJob() override
Profiler(const edm::ParameterSet &)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
virtual void endJob() override
tuple cout
Definition: gather_cfg.py:121