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.3 2007/03/11 08:20:18 innocent 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 void
96 {
97 m_evtCount++;
98 if(m_evtCount >= m_firstEvent && (m_evtCount <= m_lastEvent || m_lastEvent == -1))
99  {
100  switch (m_action)
101  {
102  case 0:
103  CALLGRIND_STOP_INSTRUMENTATION;
104  cout << "Stop Instr" << endl;
105  break;
106  case 1:
107  CALLGRIND_START_INSTRUMENTATION;
108  CALLGRIND_DUMP_STATS;
109  cout << "Start Instr" << endl;
110  break;
111  case 2:
112  CALLGRIND_DUMP_STATS;
113  cout << "Dump stat" << endl;
114  break;
115 
116  }
117 
118  }
119 }
120 
121 
122 // ------------ method called once each job just before starting event loop ------------
123 void
125 {
126 }
127 
128 // ------------ method called once each job just after ending the event loop ------------
129 void
131 }
132 
133 //define this as a plug-in
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T getParameter(std::string const &) const
#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:41
virtual void beginJob()