CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
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 ---------------------------
50  int m_action;
52 };
53 
54 //
55 // constants, enums and typedefs
56 //
57 
58 //
59 // static data member definitions
60 //
61 
62 //
63 // constructors and destructor
64 //
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 
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 ------------
109 
110 // ------------ method called once each job just after ending the event loop ------------
112 
113 //define this as a plug-in
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
void beginJob()
Definition: Breakpoints.cc:14
int iEvent
Definition: GenABIO.cc:224
~Profiler() override
void beginJob() override
Profiler(const edm::ParameterSet &)
void analyze(const edm::Event &, const edm::EventSetup &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void endJob() override
tuple cout
Definition: gather_cfg.py:144