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