00001 #ifndef EvFTimeProfilerService_H 00002 #define EvFTimeProfilerService_H 1 00003 00004 00005 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00006 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h" 00007 #include "DataFormats/Provenance/interface/EventID.h" 00008 #include "DataFormats/Provenance/interface/Timestamp.h" 00009 #include "DataFormats/Provenance/interface/ModuleDescription.h" 00010 00011 #include "boost/thread/thread.hpp" 00012 #include <sys/time.h> 00013 00014 #include <string> 00015 #include <vector> 00016 #include <map> 00017 00018 namespace evf { 00019 00020 class TimeProfilerService 00021 { 00022 public: 00023 TimeProfilerService(const edm::ParameterSet&,edm::ActivityRegistry&); 00024 ~TimeProfilerService(); 00025 00026 void postBeginJob(); 00027 void postEndJob(); 00028 00029 void preEventProcessing(const edm::EventID&, const edm::Timestamp&); 00030 void postEventProcessing(const edm::Event&, const edm::EventSetup&); 00031 00032 void preSource(); 00033 void postSource(); 00034 00035 00036 void preModule(const edm::ModuleDescription&); 00037 void postModule(const edm::ModuleDescription&); 00038 double getFirst(std::string const &name) const; 00039 double getMax(std::string const &name) const; 00040 double getAve(std::string const &name) const; 00041 00042 private: 00043 00044 boost::mutex lock_; 00045 double curr_module_time_; // seconds 00046 struct times{ 00047 double firstEvent_; 00048 double max_; 00049 double total_; 00050 int ncalls_; 00051 }; 00052 std::map<std::string, times> profiles_; 00053 }; 00054 00055 } 00056 00057 #endif