Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032
00033
00034 #include "valgrind/callgrind.h"
00035
00036
00037
00038 #include <iostream>
00039 using namespace std;
00040 class Profiler : public edm::EDAnalyzer {
00041 public:
00042 explicit Profiler(const edm::ParameterSet&);
00043 ~Profiler();
00044
00045
00046 private:
00047 virtual void beginJob() ;
00048 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00049 virtual void endJob() ;
00050
00051
00052 int m_firstEvent;
00053 int m_lastEvent;
00054 int m_action;
00055 int m_evtCount;
00056 };
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 Profiler::Profiler(const edm::ParameterSet& parameters)
00070 {
00071
00072 m_firstEvent = parameters.getParameter<int>("firstEvent");
00073 m_lastEvent = parameters.getParameter<int>("lastEvent");
00074 m_action = parameters.getParameter<int>("action");
00075 m_evtCount=0;
00076
00077 }
00078
00079
00080 Profiler::~Profiler()
00081 {
00082
00083
00084
00085
00086 }
00087
00088
00089
00090
00091
00092
00093
00094 #pragma GCC diagnostic push
00095 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
00096 void
00097 Profiler::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00098 {
00099 m_evtCount++;
00100 if(m_evtCount >= m_firstEvent && (m_evtCount <= m_lastEvent || m_lastEvent == -1))
00101 {
00102 switch (m_action)
00103 {
00104 case 0:
00105 CALLGRIND_STOP_INSTRUMENTATION;
00106 cout << "Stop Instr" << endl;
00107 break;
00108 case 1:
00109 CALLGRIND_START_INSTRUMENTATION;
00110 CALLGRIND_DUMP_STATS;
00111 cout << "Start Instr" << endl;
00112 break;
00113 case 2:
00114 CALLGRIND_DUMP_STATS;
00115 cout << "Dump stat" << endl;
00116 break;
00117
00118 }
00119
00120 }
00121 }
00122 #pragma GCC diagnostic pop
00123
00124
00125
00126 void
00127 Profiler::beginJob()
00128 {
00129 }
00130
00131
00132 void
00133 Profiler::endJob() {
00134 }
00135
00136
00137 DEFINE_FWK_MODULE(Profiler);