File indexing completed on 2021-02-14 13:32:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/EDAnalyzer.h"
0025
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030
0031 #include "valgrind/callgrind.h"
0032
0033
0034
0035 #include <iostream>
0036 using namespace std;
0037 class Profiler : public edm::EDAnalyzer {
0038 public:
0039 explicit Profiler(const edm::ParameterSet&);
0040 ~Profiler() override;
0041
0042 private:
0043 void beginJob() override;
0044 void analyze(const edm::Event&, const edm::EventSetup&) override;
0045 void endJob() override;
0046
0047
0048 int m_firstEvent;
0049 int m_lastEvent;
0050 int m_action;
0051 int m_evtCount;
0052 };
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 Profiler::Profiler(const edm::ParameterSet& parameters) {
0066
0067 m_firstEvent = parameters.getParameter<int>("firstEvent");
0068 m_lastEvent = parameters.getParameter<int>("lastEvent");
0069 m_action = parameters.getParameter<int>("action");
0070 m_evtCount = 0;
0071 }
0072
0073 Profiler::~Profiler() {
0074
0075
0076 }
0077
0078
0079
0080
0081
0082
0083 #pragma GCC diagnostic push
0084 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
0085 void Profiler::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0086 m_evtCount++;
0087 if (m_evtCount >= m_firstEvent && (m_evtCount <= m_lastEvent || m_lastEvent == -1)) {
0088 switch (m_action) {
0089 case 0:
0090 CALLGRIND_STOP_INSTRUMENTATION;
0091 cout << "Stop Instr" << endl;
0092 break;
0093 case 1:
0094 CALLGRIND_START_INSTRUMENTATION;
0095 CALLGRIND_DUMP_STATS;
0096 cout << "Start Instr" << endl;
0097 break;
0098 case 2:
0099 CALLGRIND_DUMP_STATS;
0100 cout << "Dump stat" << endl;
0101 break;
0102 }
0103 }
0104 }
0105 #pragma GCC diagnostic pop
0106
0107
0108 void Profiler::beginJob() {}
0109
0110
0111 void Profiler::endJob() {}
0112
0113
0114 DEFINE_FWK_MODULE(Profiler);