Skip to content

Commit

Permalink
change the parameter name to dumpContextForLabels and the internal da…
Browse files Browse the repository at this point in the history
…ta structure from std::vector<std::string> to std::set<std::string> to avoid the linear lookup
  • Loading branch information
fwyzard committed Oct 24, 2013
1 parent eb6d620 commit d2dbdc7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
64 changes: 33 additions & 31 deletions FWCore/Services/src/Tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ using namespace edm::service;

Tracer::Tracer(ParameterSet const& iPS, ActivityRegistry&iRegistry) :
indention_(iPS.getUntrackedParameter<std::string>("indention")),
dumpContextForLabel_(iPS.getUntrackedParameter<std::vector<std::string>>("dumpContextForLabel")),
dumpContextForLabels_(),
dumpNonModuleContext_(iPS.getUntrackedParameter<bool>("dumpNonModuleContext"))
{
for (std::string & label: iPS.getUntrackedParameter<std::vector<std::string>>("dumpContextForLabels"))
dumpContextForLabels_.insert(std::move(label));

iRegistry.watchPostBeginJob(this, &Tracer::postBeginJob);
iRegistry.watchPostEndJob(this, &Tracer::postEndJob);

Expand Down Expand Up @@ -130,10 +133,9 @@ Tracer::Tracer(ParameterSet const& iPS, ActivityRegistry&iRegistry) :

void
Tracer::fillDescriptions(edm::ConfigurationDescriptions & descriptions) {

edm::ParameterSetDescription desc;
desc.addUntracked<std::string>("indention", "++")->setComment("Prefix characters for output. The characters are repeated to form the indentation.");
desc.addUntracked<std::vector<std::string>>("dumpContextForLabel", {""})->setComment("Prints context information to cout for the module transitions associated with these modules' labels");
desc.addUntracked<std::vector<std::string>>("dumpContextForLabels", {})->setComment("Prints context information to cout for the module transitions associated with these modules' labels");
desc.addUntracked<bool>("dumpNonModuleContext", false)->setComment("Prints context information to cout for the transitions not associated with any module label");
descriptions.add("Tracer", desc);
descriptions.setComment("This service prints each phase the framework is processing, e.g. constructing a module,running a module, etc.");
Expand Down Expand Up @@ -211,7 +213,7 @@ Tracer::preModuleBeginStream(StreamContext const& sc, ModuleCallingContext const
ModuleDescription const& desc = *mcc.moduleDescription();
LogAbsolute out("Tracer");
out << indention_ << indention_ << " starting: begin stream for module: stream = " << sc.streamID() << " label = '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -222,7 +224,7 @@ Tracer::postModuleBeginStream(StreamContext const& sc, ModuleCallingContext cons
ModuleDescription const& desc = *mcc.moduleDescription();
LogAbsolute out("Tracer");
out << indention_ << indention_ << " finished: begin stream for module: stream = " << sc.streamID() << " label = '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -233,7 +235,7 @@ Tracer::preModuleEndStream(StreamContext const& sc, ModuleCallingContext const&
ModuleDescription const& desc = *mcc.moduleDescription();
LogAbsolute out("Tracer");
out << indention_ << indention_ << " starting: end stream for module: stream = " << sc.streamID() << " label = '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -244,7 +246,7 @@ Tracer::postModuleEndStream(StreamContext const& sc, ModuleCallingContext const&
ModuleDescription const& desc = *mcc.moduleDescription();
LogAbsolute out("Tracer");
out << indention_ << indention_ << " finished: end stream for module: stream = " << sc.streamID() << " label = '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand Down Expand Up @@ -454,7 +456,7 @@ void
Tracer::preModuleConstruction(ModuleDescription const& desc) {
LogAbsolute out("Tracer");
out << indention_ << indention_ << " starting: constructing module with label '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << desc;
}
}
Expand All @@ -463,7 +465,7 @@ void
Tracer::postModuleConstruction(ModuleDescription const& desc) {
LogAbsolute out("Tracer");
out << indention_ << indention_ << " finished: constructing module with label '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << desc;
}
}
Expand All @@ -473,7 +475,7 @@ Tracer::preModuleBeginJob(ModuleDescription const& desc) {
LogAbsolute out("Tracer");
out << indention_ << indention_;
out << " starting: begin job for module with label '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << desc;
}
}
Expand All @@ -483,7 +485,7 @@ Tracer::postModuleBeginJob(ModuleDescription const& desc) {
LogAbsolute out("Tracer");
out << indention_ << indention_;
out << " finished: begin job for module with label '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << desc;
}
}
Expand All @@ -493,7 +495,7 @@ Tracer::preModuleEndJob(ModuleDescription const& desc) {
LogAbsolute out("Tracer");
out << indention_ << indention_;
out << " starting: end job for module with label '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << desc;
}
}
Expand All @@ -503,7 +505,7 @@ Tracer::postModuleEndJob(ModuleDescription const& desc) {
LogAbsolute out("Tracer");
out << indention_ << indention_;
out << " finished: end job for module with label '" << desc.moduleLabel() << "' id = " << desc.id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), desc.moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(desc.moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << desc;
}
}
Expand All @@ -516,7 +518,7 @@ Tracer::preModuleEvent(StreamContext const& sc, ModuleCallingContext const& mcc)
out << indention_;
}
out << " starting: processing event for module: stream = " << sc.streamID() << " label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -530,7 +532,7 @@ Tracer::postModuleEvent(StreamContext const& sc, ModuleCallingContext const& mcc
out << indention_;
}
out << " finished: processing event for module: stream = " << sc.streamID() << " label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -545,7 +547,7 @@ Tracer::preModuleStreamBeginRun(StreamContext const& sc, ModuleCallingContext co
out << indention_;
}
out << " starting: begin run for module: stream = " << sc.streamID() << " label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -559,7 +561,7 @@ Tracer::postModuleStreamBeginRun(StreamContext const& sc, ModuleCallingContext c
out << indention_;
}
out << " finished: begin run for module: stream = " << sc.streamID() << " label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -573,7 +575,7 @@ Tracer::preModuleStreamEndRun(StreamContext const& sc, ModuleCallingContext cons
out << indention_;
}
out << " starting: end run for module: stream = " << sc.streamID() << " label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -587,7 +589,7 @@ Tracer::postModuleStreamEndRun(StreamContext const& sc, ModuleCallingContext con
out << indention_;
}
out << " finished: end run for module: stream = " << sc.streamID() << " label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -601,7 +603,7 @@ Tracer::preModuleStreamBeginLumi(StreamContext const& sc, ModuleCallingContext c
out << indention_;
}
out << " starting: begin lumi for module: stream = " << sc.streamID() << " label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -615,7 +617,7 @@ Tracer::postModuleStreamBeginLumi(StreamContext const& sc, ModuleCallingContext
out << indention_;
}
out << " finished: begin lumi for module: stream = " << sc.streamID() << " label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -629,7 +631,7 @@ Tracer::preModuleStreamEndLumi(StreamContext const& sc, ModuleCallingContext con
out << indention_;
}
out << " starting: end lumi for module: stream = " << sc.streamID() << " label = '"<< mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -643,7 +645,7 @@ Tracer::postModuleStreamEndLumi(StreamContext const& sc, ModuleCallingContext co
out << indention_;
}
out << " finished: end lumi for module: stream = " << sc.streamID() << " label = '"<< mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << sc;
out << mcc;
}
Expand All @@ -657,7 +659,7 @@ Tracer::preModuleGlobalBeginRun(GlobalContext const& gc, ModuleCallingContext co
out << indention_;
}
out << " starting: global begin run for module: label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << gc;
out << mcc;
}
Expand All @@ -671,7 +673,7 @@ Tracer::postModuleGlobalBeginRun(GlobalContext const& gc, ModuleCallingContext c
out << indention_;
}
out << " finished: global begin run for module: label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << gc;
out << mcc;
}
Expand All @@ -685,7 +687,7 @@ Tracer::preModuleGlobalEndRun(GlobalContext const& gc, ModuleCallingContext cons
out << indention_;
}
out << " starting: global end run for module: label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << gc;
out << mcc;
}
Expand All @@ -699,7 +701,7 @@ Tracer::postModuleGlobalEndRun(GlobalContext const& gc, ModuleCallingContext con
out << indention_;
}
out << " finished: global end run for module: label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << gc;
out << mcc;
}
Expand All @@ -713,7 +715,7 @@ Tracer::preModuleGlobalBeginLumi(GlobalContext const& gc, ModuleCallingContext c
out << indention_;
}
out << " starting: global begin lumi for module: label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << gc;
out << mcc;
}
Expand All @@ -727,7 +729,7 @@ Tracer::postModuleGlobalBeginLumi(GlobalContext const& gc, ModuleCallingContext
out << indention_;
}
out << " finished: global begin lumi for module: label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << gc;
out << mcc;
}
Expand All @@ -741,7 +743,7 @@ Tracer::preModuleGlobalEndLumi(GlobalContext const& gc, ModuleCallingContext con
out << indention_;
}
out << " starting: global end lumi for module: label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << gc;
out << mcc;
}
Expand All @@ -755,7 +757,7 @@ Tracer::postModuleGlobalEndLumi(GlobalContext const& gc, ModuleCallingContext co
out << indention_;
}
out << " finished: global end lumi for module: label = '" << mcc.moduleDescription()->moduleLabel() << "'" << "' id = " << mcc.moduleDescription()->id();
if(std::find(dumpContextForLabel_.begin(), dumpContextForLabel_.end(), mcc.moduleDescription()->moduleLabel()) != dumpContextForLabel_.end()) {
if(dumpContextForLabels_.find(mcc.moduleDescription()->moduleLabel()) != dumpContextForLabels_.end()) {
out << "\n" << gc;
out << mcc;
}
Expand Down
3 changes: 2 additions & 1 deletion FWCore/Services/src/Tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"

#include <string>
#include <set>

namespace edm {
class ConfigurationDescriptions;
Expand Down Expand Up @@ -138,7 +139,7 @@ namespace edm {

private:
std::string indention_;
std::vector<std::string> dumpContextForLabel_;
std::set<std::string> dumpContextForLabels_;
bool dumpNonModuleContext_;
};
}
Expand Down

0 comments on commit d2dbdc7

Please sign in to comment.