CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ModuleTiming.h
Go to the documentation of this file.
1 #ifndef Edm_Module_Timing_h
2 #define Edm_Module_Timing_h
3 
4 #include <vector>
5 #include <string>
6 
7 /* Original version: July 2006, Christos Leonidopoulos */
8 
9 namespace edm
10 {
11 
12  // structure holding the processing time (per event) and name of a module
13  class ModuleTime
14  {
15  public:
16  ModuleTime(): name_(""), time_(-1) {}
17  ModuleTime(std::string Name, double Time): name_(Name), time_(Time) {}
19 
20  std::string name() const {return name_;} // module name ("label")
21  double time() const {return time_;} // processing time for event (secs)
22  private:
23  std::string name_;
24  double time_;
25  };
26 
27  // structure holding processing info for all modules in event (+total time)
28  class EventTime
29  {
30  private:
31  std::vector<ModuleTime> moduleSet;
32  double tot_time_; // total time in event for all modules (in secs)
33 
34  public:
37 
38  // # of modules contained in event
39  unsigned size() const{return moduleSet.size();}
40  // get hold of ModuleTime structure for module #i, where 0 <= i < size()
41  const ModuleTime & moduleTime(unsigned i)
42  {
43  return moduleSet.at(i);
44  }
45  // get total processing time for event (secs)
46  double tot_time() const {return tot_time_;}
47  // get name for module #i, where 0 <= i < size()
48  std::string name(unsigned i) const
49  {
50  return moduleSet.at(i).name();
51  }
52  // get processing time for module #i (secs), where 0 <= i < size()
53  double time(unsigned i) const
54  {
55  return moduleSet.at(i).time();
56  }
57  // add module structure to event
58  void addModuleTime(const ModuleTime & m)
59  {
60  moduleSet.push_back(m);
61  tot_time_ += m.time();
62  }
63 
64  // reset all info (ie. from previous event)
65  void reset()
66  {moduleSet.clear(); tot_time_ = 0;}
67 
68  };
69 
70 
71 }
72 
73 #endif // #define Edm_Module_Timing_h
int i
Definition: DBlmapReader.cc:9
std::string name_
Definition: ModuleTiming.h:23
const ModuleTime & moduleTime(unsigned i)
Definition: ModuleTiming.h:41
double time() const
Definition: ModuleTiming.h:21
double tot_time() const
Definition: ModuleTiming.h:46
unsigned size() const
Definition: ModuleTiming.h:39
void addModuleTime(const ModuleTime &m)
Definition: ModuleTiming.h:58
double time(unsigned i) const
Definition: ModuleTiming.h:53
std::string name() const
Definition: ModuleTiming.h:20
double tot_time_
Definition: ModuleTiming.h:32
std::vector< ModuleTime > moduleSet
Definition: ModuleTiming.h:31
std::string name(unsigned i) const
Definition: ModuleTiming.h:48
ModuleTime(std::string Name, double Time)
Definition: ModuleTiming.h:17