CMS 3D CMS Logo

HLTPerformanceInfo.h
Go to the documentation of this file.
1 // -*-c++-*-
2 #ifndef HLTPERFORMANCEINFO_H
3 #define HLTPERFORMANCEINFO_H
4 
5 #include <string>
6 #include <vector>
7 #include <cassert>
8 
11 
13 public:
14  class Path;
15  class Module;
16  typedef std::vector<Path> PathList;
17  typedef std::vector<Module> Modules;
18  typedef std::vector<cms_uint32_t> ModulesInPath;
20  //
21  class Module {
22  private:
23  std::string name_; // module instance name
24  double dt_; // Wall-clock time
25  double dtCPU_; // CPU time
26  // I am using this even for modules....
28 
29  public:
30  Module() : name_("unknown") {}
31  // new constructor adding cpu time
32  Module(const char *n, const double dt, const double dtCPU, edm::HLTPathStatus stat = edm::hlt::Ready)
33  : name_(n), dt_(dt), dtCPU_(dtCPU), status_(stat) {}
34  std::string name() const { return name_; }
35  double time() const { return dt_; }
36  double cputime() const { return dtCPU_; }
37  edm::HLTPathStatus status() const { return status_; }
38  bool operator==(const char *tname) { return std::string(tname) == name(); }
39  void clear() {
40  dt_ = 0;
41  dtCPU_ = 0;
42  status_.reset(); // = edm::hlt::Ready;
43  }
44  void setTime(double t) { dt_ = t; }
45  void setCPUTime(double t) { dtCPU_ = t; }
47  // pw - can't a module be on different paths?
48  //void setStatusByPath(Path *path) ;
49  //int indexInPath(Path path) const ;
50  };
51  // end Module class definition
52 
53  // in this version the module can no longer iterate over the paths
54  // by itself, since it has no access to the actual module list.
55  class Path {
56  private:
58  ModulesInPath moduleView_; // indices into the module vector
60 
61  public:
62  Path(const std::string n = "unknown") : name_(n), moduleView_(), status_() {}
63  std::string name() const { return name_; }
65 
66  edm::HLTPathStatus status() const { return status_; }
67  void clear() {
68  status_.reset();
69  // time is dynamic, nothing to reset
70  }
71  bool operator==(const char *tname) { return (std::string(tname) == name()); }
72 
73  const size_t operator[](size_t m) const { return moduleView_.at(m); }
74 
75  void addModuleRef(size_t m) { moduleView_.push_back(m); }
76 
77  ModulesInPath::const_iterator begin() { return moduleView_.begin(); }
78  ModulesInPath::const_iterator end() { return moduleView_.end(); }
79  size_t getModuleIndex(size_t j) const { return moduleView_.at(j); }
80 
81  size_t numberOfModules() const { return moduleView_.size(); };
82  };
83  // end Path class definition
84 private:
87 
88 public:
89  void addPath(const Path &p) { paths_.push_back(p); }
90  void addModule(const Module &m) { modules_.push_back(m); }
91  // by name
92  void addModuleToPath(const char *mod, const char *path) {
93  // first make sure module exists
94  Modules::iterator m = findModule(mod);
95  if (m == endModules()) {
96  // new module - create it and stick it on the end
97  Module newMod(mod, 0, 0); // time (wall and cpu) = 0 since it wasn't run
98  modules_.push_back(newMod);
99  }
100 
101  for (size_t i = 0; i < paths_.size(); ++i) {
102  if (!(paths_[i] == path))
103  continue;
104  // we found the path, add module to the end
105  for (size_t j = 0; j < modules_.size(); ++j) {
106  if (!(modules_[j] == mod))
107  continue;
108  paths_[i].addModuleRef(j);
109  break;
110  }
111  break;
112  }
113  }
114  // by index
115  void addModuleToPath(const size_t mod, const size_t path) {
116  assert((path < paths_.size()) && (mod < modules_.size()));
117  paths_[path].addModuleRef(mod);
118  }
119 
120  void clear() {
121  modules_.clear();
122  paths_.clear();
123  }
124  void clearModules() {
125  for (size_t i = 0; i < modules_.size(); ++i) {
126  modules_[i].clear();
127  }
128  }
129 
130  // non-const?
131  const Module &getModuleOnPath(size_t m, size_t p) const;
132  const Module &getModule(size_t m) const { return modules_.at(m); }
133  const Path &getPath(size_t p) const { return paths_.at(p); }
134 
135  // find a module, given its name.
136  // returns endModules() on failure
137  Modules::iterator findModule(const char *moduleInstanceName);
138  PathList::iterator findPath(const char *pathName);
139 
140  int moduleIndexInPath(const char *mod, const char *path);
141 
142  size_t numberOfPaths() const { return paths_.size(); }
143  size_t numberOfModules() const { return modules_.size(); }
144 
145  PathList::iterator beginPaths() { return paths_.begin(); }
146  PathList::iterator endPaths() { return paths_.end(); }
147 
148  Modules::const_iterator beginModules() const { return modules_.begin(); }
149 
150  Modules::const_iterator endModules() const { return modules_.end(); }
151 
152  double totalTime() const;
153  double totalCPUTime() const;
154  double longestModuleTime() const;
155  double longestModuleCPUTime() const;
158 
159  double totalPathTime(const size_t path);
160  double totalPathCPUTime(const size_t path);
161 
162  void setStatusOfModulesFromPath(const char *pathName);
163 
164  // double lastModuleOnPathTime(const size_t pathnumber);
165  // double lastModuleOnPathCPUTime(const size_t pathnumber);
166 
167  // is this module only on one path?
168  bool uniqueModule(const char *mod) const;
169 };
170 
171 typedef std::vector<HLTPerformanceInfo> HLTPerformanceInfoCollection;
172 
173 #endif // HLTPERFORMANCEINFO_H
HLTPerformanceInfo::Module::status
edm::HLTPathStatus status() const
Definition: HLTPerformanceInfo.h:37
HLTPerformanceInfo::totalTime
double totalTime() const
Definition: HLTPerformanceInfo.cc:20
HLTPerformanceInfo::numberOfPaths
size_t numberOfPaths() const
Definition: HLTPerformanceInfo.h:142
HLTPerformanceInfo::Path::addModuleRef
void addModuleRef(size_t m)
Definition: HLTPerformanceInfo.h:75
HLTPerformanceInfo::totalPathCPUTime
double totalPathCPUTime(const size_t path)
Definition: HLTPerformanceInfo.cc:49
HLTPerformanceInfo::longestModuleCPUTime
double longestModuleCPUTime() const
Definition: HLTPerformanceInfo.cc:70
mps_fire.i
i
Definition: mps_fire.py:355
HLTPerformanceInfo::uniqueModule
bool uniqueModule(const char *mod) const
Definition: HLTPerformanceInfo.cc:122
HLTPerformanceInfo::PathList
std::vector< Path > PathList
Definition: HLTPerformanceInfo.h:15
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HLTPerformanceInfo::Path::moduleView_
ModulesInPath moduleView_
Definition: HLTPerformanceInfo.h:58
HLTPerformanceInfo::Path::getModuleIndex
size_t getModuleIndex(size_t j) const
Definition: HLTPerformanceInfo.h:79
Module
#define Module(md)
Definition: vmac.h:203
HLTPerformanceInfo::Path::name_
std::string name_
Definition: HLTPerformanceInfo.h:57
HLTPerformanceInfo::Module::cputime
double cputime() const
Definition: HLTPerformanceInfo.h:36
HLTPerformanceInfo::clearModules
void clearModules()
Definition: HLTPerformanceInfo.h:124
HLTPerformanceInfo::Module::name_
std::string name_
Definition: HLTPerformanceInfo.h:23
HLTPerformanceInfo::addModule
void addModule(const Module &m)
Definition: HLTPerformanceInfo.h:90
HLTPerformanceInfo::getModuleOnPath
const Module & getModuleOnPath(size_t m, size_t p) const
Definition: HLTPerformanceInfo.cc:115
HLTPerformanceInfo::beginPaths
PathList::iterator beginPaths()
Definition: HLTPerformanceInfo.h:145
HLTPerformanceInfo::endPaths
PathList::iterator endPaths()
Definition: HLTPerformanceInfo.h:146
HLTPerformanceInfo::Path::numberOfModules
size_t numberOfModules() const
Definition: HLTPerformanceInfo.h:81
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
cms::cuda::assert
assert(be >=bs)
HLTPerformanceInfo::Module::time
double time() const
Definition: HLTPerformanceInfo.h:35
HLTPerformanceInfo::longestModuleTime
double longestModuleTime() const
Definition: HLTPerformanceInfo.cc:62
HLTPerformanceInfo::Path::setStatus
void setStatus(const edm::HLTPathStatus &result)
Definition: HLTPerformanceInfo.h:64
HLTPerformanceInfo::HLTPerformanceInfo
HLTPerformanceInfo()
Definition: HLTPerformanceInfo.cc:6
HLTPerformanceInfo::addPath
void addPath(const Path &p)
Definition: HLTPerformanceInfo.h:89
HLTPerformanceInfo::longestModuleCPUTimeName
std::string longestModuleCPUTimeName() const
Definition: HLTPerformanceInfo.cc:90
HLTPathStatus.h
HLTPerformanceInfo::Module::Module
Module()
Definition: HLTPerformanceInfo.h:30
HLTPerformanceInfo::findPath
PathList::iterator findPath(const char *pathName)
Definition: HLTPerformanceInfo.cc:11
dt
float dt
Definition: AMPTWrapper.h:136
HLTPerformanceInfo::Path::status_
edm::HLTPathStatus status_
Definition: HLTPerformanceInfo.h:59
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1111
hltMonBTagIPClient_cfi.pathName
pathName
Definition: hltMonBTagIPClient_cfi.py:5
HLTPerformanceInfo::Path::end
ModulesInPath::const_iterator end()
Definition: HLTPerformanceInfo.h:78
HLTPerformanceInfo::getModule
const Module & getModule(size_t m) const
Definition: HLTPerformanceInfo.h:132
HLTPerformanceInfo::clear
void clear()
Definition: HLTPerformanceInfo.h:120
HLTPerformanceInfo::Module::name
std::string name() const
Definition: HLTPerformanceInfo.h:34
HLTPerformanceInfo::Module::Module
Module(const char *n, const double dt, const double dtCPU, edm::HLTPathStatus stat=edm::hlt::Ready)
Definition: HLTPerformanceInfo.h:32
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
HLTPerformanceInfo::numberOfModules
size_t numberOfModules() const
Definition: HLTPerformanceInfo.h:143
HLTPerformanceInfo::totalPathTime
double totalPathTime(const size_t path)
Definition: HLTPerformanceInfo.cc:36
HLTPerformanceInfo::Module::dt_
double dt_
Definition: HLTPerformanceInfo.h:24
typedefs.h
HLTPerformanceInfo::Path::clear
void clear()
Definition: HLTPerformanceInfo.h:67
HLTPerformanceInfo::getPath
const Path & getPath(size_t p) const
Definition: HLTPerformanceInfo.h:133
HLTPerformanceInfo::Module::operator==
bool operator==(const char *tname)
Definition: HLTPerformanceInfo.h:38
cond::persistency::GLOBAL_TAG::tname
static constexpr char const * tname
Definition: GTSchema.h:13
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTPerformanceInfo::totalCPUTime
double totalCPUTime() const
Definition: HLTPerformanceInfo.cc:28
HLTPerformanceInfo::Module
Definition: HLTPerformanceInfo.h:21
HLTPerformanceInfo::Path::operator[]
const size_t operator[](size_t m) const
Definition: HLTPerformanceInfo.h:73
HLTPerformanceInfo::setStatusOfModulesFromPath
void setStatusOfModulesFromPath(const char *pathName)
Definition: HLTPerformanceInfo.cc:155
edm::HLTPathStatus
Definition: HLTPathStatus.h:33
edm::hlt::Ready
not [yet] run
Definition: HLTenums.h:17
edm::HLTPathStatus::reset
void reset()
reset this path
Definition: HLTPathStatus.h:54
HLTPerformanceInfo::Path::name
std::string name() const
Definition: HLTPerformanceInfo.h:63
HLTPerformanceInfo::findModule
Modules::iterator findModule(const char *moduleInstanceName)
Definition: HLTPerformanceInfo.cc:16
HLTPerformanceInfo::Module::setTime
void setTime(double t)
Definition: HLTPerformanceInfo.h:44
HLTPerformanceInfo::moduleIndexInPath
int moduleIndexInPath(const char *mod, const char *path)
Definition: HLTPerformanceInfo.cc:139
HLTPerformanceInfo::beginModules
Modules::const_iterator beginModules() const
Definition: HLTPerformanceInfo.h:148
HLTPerformanceInfo::modules_
Modules modules_
Definition: HLTPerformanceInfo.h:86
HLTPerformanceInfo::Path::status
edm::HLTPathStatus status() const
Definition: HLTPerformanceInfo.h:66
HLTPerformanceInfo::Path::begin
ModulesInPath::const_iterator begin()
Definition: HLTPerformanceInfo.h:77
Modules
Definition: Modules.py:1
mps_fire.result
result
Definition: mps_fire.py:303
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
HLTPerformanceInfo::paths_
PathList paths_
Definition: HLTPerformanceInfo.h:85
HLTPerformanceInfo
Definition: HLTPerformanceInfo.h:12
HLTPerformanceInfo::Module::setCPUTime
void setCPUTime(double t)
Definition: HLTPerformanceInfo.h:45
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HLTPerformanceInfo::Path
Definition: HLTPerformanceInfo.h:55
HLTPerformanceInfoCollection
std::vector< HLTPerformanceInfo > HLTPerformanceInfoCollection
Definition: HLTPerformanceInfo.h:171
HLTPerformanceInfo::addModuleToPath
void addModuleToPath(const size_t mod, const size_t path)
Definition: HLTPerformanceInfo.h:115
HLTPerformanceInfo::Module::setStatus
void setStatus(edm::HLTPathStatus status)
Definition: HLTPerformanceInfo.h:46
HLTPerformanceInfo::addModuleToPath
void addModuleToPath(const char *mod, const char *path)
Definition: HLTPerformanceInfo.h:92
HLTPerformanceInfo::Modules
std::vector< Module > Modules
Definition: HLTPerformanceInfo.h:17
HLTPerformanceInfo::Module::clear
void clear()
Definition: HLTPerformanceInfo.h:39
HLTPerformanceInfo::Path::operator==
bool operator==(const char *tname)
Definition: HLTPerformanceInfo.h:71
HLTPerformanceInfo::Module::status_
edm::HLTPathStatus status_
Definition: HLTPerformanceInfo.h:27
HLTPerformanceInfo::ModulesInPath
std::vector< cms_uint32_t > ModulesInPath
Definition: HLTPerformanceInfo.h:18
HLTPerformanceInfo::endModules
Modules::const_iterator endModules() const
Definition: HLTPerformanceInfo.h:150
HLTPerformanceInfo::Module::dtCPU_
double dtCPU_
Definition: HLTPerformanceInfo.h:25
HLTPerformanceInfo::Path::Path
Path(const std::string n="unknown")
Definition: HLTPerformanceInfo.h:62
HLTPerformanceInfo::longestModuleTimeName
std::string longestModuleTimeName() const
Definition: HLTPerformanceInfo.cc:78