Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:40

0001 #ifndef Edm_Module_Timing_h
0002 #define Edm_Module_Timing_h
0003 
0004 #include <vector>
0005 #include <string>
0006 
0007 /* Original version: July 2006, Christos Leonidopoulos */
0008 
0009 namespace edm {
0010 
0011   // structure holding the processing time (per event) and name of a module
0012   class ModuleTime {
0013   public:
0014     ModuleTime() : name_(""), time_(-1) {}
0015     ModuleTime(std::string Name, double Time) : name_(Name), time_(Time) {}
0016     ~ModuleTime() {}
0017 
0018     std::string name() const { return name_; }  // module name ("label")
0019     double time() const { return time_; }       // processing time for event (secs)
0020   private:
0021     std::string name_;
0022     double time_;
0023   };
0024 
0025   // structure holding processing info for all modules in event (+total time)
0026   class EventTime {
0027   private:
0028     std::vector<ModuleTime> moduleSet;
0029     double tot_time_;  // total time in event for all modules (in secs)
0030 
0031   public:
0032     EventTime() { reset(); }
0033     ~EventTime() {}
0034 
0035     // # of modules contained in event
0036     unsigned size() const { return moduleSet.size(); }
0037     // get hold of ModuleTime structure for module #i, where 0 <= i < size()
0038     const ModuleTime& moduleTime(unsigned i) { return moduleSet.at(i); }
0039     // get total processing time for event (secs)
0040     double tot_time() const { return tot_time_; }
0041     // get name for module #i, where 0 <= i < size()
0042     std::string name(unsigned i) const { return moduleSet.at(i).name(); }
0043     // get processing time for module #i (secs), where 0 <= i < size()
0044     double time(unsigned i) const { return moduleSet.at(i).time(); }
0045     // add module structure to event
0046     void addModuleTime(const ModuleTime& m) {
0047       moduleSet.push_back(m);
0048       tot_time_ += m.time();
0049     }
0050 
0051     // reset all info (ie. from previous event)
0052     void reset() {
0053       moduleSet.clear();
0054       tot_time_ = 0;
0055     }
0056   };
0057 
0058 }  // namespace edm
0059 
0060 #endif  // #define Edm_Module_Timing_h