Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:15:37

0001 // -*- C++ -*-
0002 //
0003 // Package:    PerfTools/Callgrind
0004 // Class:      ProfilerAnalyzer
0005 //
0006 /**\class ProfilerAnalyzer ProfilerAnalyzer.cc PerfTools/Callgrind/plugins/ProfilerAnalyzer.cc
0007 
0008  Description: an Module that either start or stop profiling
0009 
0010 
0011  Implementation:
0012     ask the ProfileService to either start or stop profiling depeding on a Parameter Set
0013     
0014 
0015   \author Vincenzo Innocente
0016 
0017 */
0018 //
0019 // Original Author:  Andrea Rizzi
0020 //         Created:  Thu Jan 18 10:34:18 CET 2007
0021 
0022 // system include files
0023 
0024 // user include files
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0027 
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 
0030 #include "FWCore/ServiceRegistry/interface/Service.h"
0031 #include "PerfTools/Callgrind/interface/ProfilerService.h"
0032 
0033 //
0034 // class declaration
0035 //
0036 class ProfilerAnalyzer : public edm::one::EDAnalyzer<> {
0037 public:
0038   explicit ProfilerAnalyzer(const edm::ParameterSet&);
0039   ~ProfilerAnalyzer() override;
0040 
0041 private:
0042   void beginJob() override;
0043   void analyze(const edm::Event&, const edm::EventSetup&) override = 0;
0044   void endJob() override;
0045 };
0046 
0047 class StartProfilerAnalyzer : public ProfilerAnalyzer {
0048 public:
0049   explicit StartProfilerAnalyzer(const edm::ParameterSet& pset) : ProfilerAnalyzer(pset) {}
0050   ~StartProfilerAnalyzer() override {}
0051 
0052 private:
0053   void analyze(const edm::Event&, const edm::EventSetup&) override;
0054 };
0055 
0056 class StopProfilerAnalyzer : public ProfilerAnalyzer {
0057 public:
0058   explicit StopProfilerAnalyzer(const edm::ParameterSet& pset) : ProfilerAnalyzer(pset) {}
0059   ~StopProfilerAnalyzer() override {}
0060 
0061 private:
0062   void analyze(const edm::Event&, const edm::EventSetup&) override;
0063 };
0064 
0065 //
0066 // constants, enums and typedefs
0067 //
0068 
0069 //
0070 // static data member definitions
0071 //
0072 
0073 //
0074 // constructors and destructor
0075 //
0076 ProfilerAnalyzer::ProfilerAnalyzer(const edm::ParameterSet&) {}
0077 
0078 ProfilerAnalyzer::~ProfilerAnalyzer() {
0079   // do anything here that needs to be done at desctruction time
0080   // (e.g. close files, deallocate resources etc.)
0081 }
0082 
0083 //
0084 // member functions
0085 //
0086 
0087 // ------------ method called to for each event  ------------
0088 void StartProfilerAnalyzer::analyze(const edm::Event&, const edm::EventSetup&) {
0089   edm::Service<ProfilerService>()->startInstrumentation();
0090 }
0091 void StopProfilerAnalyzer::analyze(const edm::Event&, const edm::EventSetup&) {
0092   edm::Service<ProfilerService>()->stopInstrumentation();
0093 }
0094 
0095 // ------------ method called once each job just before starting event loop  ------------
0096 void ProfilerAnalyzer::beginJob() {}
0097 
0098 // ------------ method called once each job just after ending the event loop  ------------
0099 void ProfilerAnalyzer::endJob() {}
0100 
0101 //define this as a plug-in
0102 DEFINE_FWK_MODULE(StartProfilerAnalyzer);
0103 DEFINE_FWK_MODULE(StopProfilerAnalyzer);