CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/PerfTools/Callgrind/plugins/ProfilerAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    PerfTools/Callgrind
00004 // Class:      ProfilerAnalyzer
00005 // 
00018 // 
00019 // Original Author:  Andrea Rizzi
00020 //         Created:  Thu Jan 18 10:34:18 CET 2007
00021 
00022 
00023 
00024 // system include files
00025 
00026 
00027 // user include files
00028 #include "FWCore/Framework/interface/Frameworkfwd.h"
00029 #include "FWCore/Framework/interface/EDAnalyzer.h"
00030 
00031 #include "FWCore/Framework/interface/MakerMacros.h"
00032 
00033 #include "FWCore/ServiceRegistry/interface/Service.h"
00034 #include "PerfTools/Callgrind/interface/ProfilerService.h"
00035 
00036 //
00037 // class declaration
00038 //
00039 class ProfilerAnalyzer : public edm::EDAnalyzer {
00040 public:
00041   explicit ProfilerAnalyzer(const edm::ParameterSet&);
00042   ~ProfilerAnalyzer();
00043 
00044 
00045 private:
00046   virtual void beginJob();
00047   virtual void analyze(const edm::Event&, const edm::EventSetup&)=0;
00048   virtual void endJob() ;
00049 
00050 };
00051 
00052 class StartProfilerAnalyzer : public ProfilerAnalyzer {
00053 public:
00054   explicit StartProfilerAnalyzer(const edm::ParameterSet & pset) :
00055     ProfilerAnalyzer(pset) {}
00056   ~StartProfilerAnalyzer(){}
00057 
00058 
00059 private:
00060   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00061 
00062 };
00063 
00064 class StopProfilerAnalyzer : public ProfilerAnalyzer {
00065 public:
00066   explicit StopProfilerAnalyzer(const edm::ParameterSet & pset) :
00067     ProfilerAnalyzer(pset) {}
00068   ~StopProfilerAnalyzer(){}
00069 
00070 private:
00071   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00072 
00073 };
00074 
00075 
00076 //
00077 // constants, enums and typedefs
00078 //
00079 
00080 //
00081 // static data member definitions
00082 //
00083 
00084 //
00085 // constructors and destructor
00086 //
00087 ProfilerAnalyzer::ProfilerAnalyzer(const edm::ParameterSet&)
00088 {
00089 }
00090 
00091 
00092 ProfilerAnalyzer::~ProfilerAnalyzer()
00093 {
00094  
00095    // do anything here that needs to be done at desctruction time
00096    // (e.g. close files, deallocate resources etc.)
00097 
00098 }
00099 
00100 
00101 //
00102 // member functions
00103 //
00104 
00105 // ------------ method called to for each event  ------------
00106 void
00107 StartProfilerAnalyzer::analyze(const edm::Event&, const edm::EventSetup&)
00108 {
00109   edm::Service<ProfilerService>()->startInstrumentation();
00110 }
00111 void
00112 StopProfilerAnalyzer::analyze(const edm::Event&, const edm::EventSetup&)
00113 {
00114   edm::Service<ProfilerService>()->stopInstrumentation();
00115 }
00116 
00117 
00118 // ------------ method called once each job just before starting event loop  ------------
00119 void 
00120 ProfilerAnalyzer::beginJob()
00121 {
00122 }
00123 
00124 // ------------ method called once each job just after ending the event loop  ------------
00125 void 
00126 ProfilerAnalyzer::endJob() {
00127 }
00128 
00129 //define this as a plug-in
00130 DEFINE_FWK_MODULE(StartProfilerAnalyzer);
00131 DEFINE_FWK_MODULE(StopProfilerAnalyzer);