CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
edm::service::Timing Class Reference

#include <Timing.h>

Public Member Functions

 Timing (ParameterSet const &, ActivityRegistry &)
 
 ~Timing ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Public Attributes

sigc::signal< void,
ModuleDescription const
&, double > 
newMeasurementSignal
 

Private Member Functions

void postBeginJob ()
 
void postEndJob ()
 
void postEventProcessing (Event const &, EventSetup const &)
 
void postModule (ModuleDescription const &)
 
void preEventProcessing (EventID const &, Timestamp const &)
 
void preModule (ModuleDescription const &)
 

Private Attributes

EventID curr_event_
 
double curr_event_cpu_
 
double curr_event_time_
 
double curr_job_cpu_
 
double curr_job_time_
 
double curr_module_time_
 
double max_event_cpu_
 
double max_event_time_
 
double min_event_cpu_
 
double min_event_time_
 
bool report_summary_
 
bool summary_only_
 
int total_event_count_
 
double total_event_cpu_
 

Detailed Description

Definition at line 35 of file Timing.h.

Constructor & Destructor Documentation

edm::service::Timing::Timing ( ParameterSet const &  iPS,
ActivityRegistry iRegistry 
)

Definition at line 81 of file Timing.cc.

References postBeginJob(), postEndJob(), postEventProcessing(), postModule(), preEventProcessing(), preModule(), summary_only_, edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostModule(), edm::ActivityRegistry::watchPostProcessEvent(), edm::ActivityRegistry::watchPreModule(), and edm::ActivityRegistry::watchPreProcessEvent().

81  :
82  curr_event_(),
83  curr_job_time_(0.),
84  curr_job_cpu_(0.),
85  curr_event_time_(0.),
86  curr_event_cpu_(0.),
88  total_event_cpu_(0.),
89  summary_only_(iPS.getUntrackedParameter<bool>("summaryOnly")),
90  report_summary_(iPS.getUntrackedParameter<bool>("useJobReport")),
91  max_event_time_(0.),
92  max_event_cpu_(0.),
93  min_event_time_(0.),
94  min_event_cpu_(0.),
96  iRegistry.watchPostBeginJob(this, &Timing::postBeginJob);
97  iRegistry.watchPostEndJob(this, &Timing::postEndJob);
98 
99  iRegistry.watchPreProcessEvent(this, &Timing::preEventProcessing);
100  iRegistry.watchPostProcessEvent(this, &Timing::postEventProcessing);
101 
102  if (not summary_only_) {
103  iRegistry.watchPreModule(this, &Timing::preModule);
104  iRegistry.watchPostModule(this, &Timing::postModule);
105  }
106  }
double curr_job_time_
Definition: Timing.h:54
double max_event_time_
Definition: Timing.h:66
bool report_summary_
Definition: Timing.h:61
double curr_event_cpu_
Definition: Timing.h:57
double curr_job_cpu_
Definition: Timing.h:55
void preModule(ModuleDescription const &)
Definition: Timing.cc:219
EventID curr_event_
Definition: Timing.h:53
double curr_module_time_
Definition: Timing.h:58
void postModule(ModuleDescription const &)
Definition: Timing.cc:223
double max_event_cpu_
Definition: Timing.h:67
double total_event_cpu_
Definition: Timing.h:59
int total_event_count_
Definition: Timing.h:70
double min_event_cpu_
Definition: Timing.h:69
void preEventProcessing(EventID const &, Timestamp const &)
Definition: Timing.cc:184
void postEventProcessing(Event const &, EventSetup const &)
Definition: Timing.cc:190
double min_event_time_
Definition: Timing.h:68
double curr_event_time_
Definition: Timing.h:56
edm::service::Timing::~Timing ( )

Definition at line 108 of file Timing.cc.

108  {
109  }

Member Function Documentation

void edm::service::Timing::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 111 of file Timing.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), and edm::ConfigurationDescriptions::setComment().

111  {
113  desc.addUntracked<bool>("summaryOnly", false)->setComment(
114  "If 'true' do not report timing for each event");
115  desc.addUntracked<bool>("useJobReport", true)->setComment(
116  "If 'true' write summary information to JobReport");
117  descriptions.add("Timing", desc);
118  descriptions.setComment(
119  "This service reports the time it takes to run each module in a job.");
120  }
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void edm::service::Timing::postBeginJob ( )
private

Definition at line 122 of file Timing.cc.

References curr_job_cpu_, curr_job_time_, edm::service::getCPU(), edm::service::getTime(), summary_only_, and total_event_cpu_.

Referenced by Timing().

122  {
124  curr_job_cpu_ = getCPU();
125  total_event_cpu_ = 0.0;
126 
127  //LogInfo("TimeReport")
128  if (not summary_only_) {
129  LogImportant("TimeReport") // ChangeLog 3
130  << "TimeReport> Report activated" << "\n"
131  << "TimeReport> Report columns headings for events: "
132  << "eventnum runnum timetaken\n"
133  << "TimeReport> Report columns headings for modules: "
134  << "eventnum runnum modulelabel modulename timetakeni\n"
135  << "TimeReport> JobTime=" << curr_job_time_ << " JobCPU=" << curr_job_cpu_ << "\n";
136  }
137  }
double curr_job_time_
Definition: Timing.h:54
static double getCPU()
Definition: Timing.cc:69
double curr_job_cpu_
Definition: Timing.h:55
double total_event_cpu_
Definition: Timing.h:59
static double getTime()
void edm::service::Timing::postEndJob ( )
private

Definition at line 139 of file Timing.cc.

References curr_job_cpu_, curr_job_time_, edm::service::d2str(), edm::service::getCPU(), edm::service::getTime(), max_event_cpu_, max_event_time_, min_event_cpu_, min_event_time_, report_summary_, total_event_count_, and total_event_cpu_.

Referenced by Timing().

139  {
140  double total_job_time = getTime() - curr_job_time_;
141  double average_event_time = total_job_time / total_event_count_;
142 
143  double total_job_cpu = getCPU() - curr_job_cpu_;
144  double average_event_cpu = total_event_cpu_ / total_event_count_;
145 
146  //LogAbsolute("FwkJob")
147  //LogAbsolute("TimeReport") // Changelog 1
148  LogImportant("TimeReport") // Changelog 3
149  << "TimeReport> Time report complete in "
150  << total_job_time << " seconds"
151  << "\n"
152  << " Time Summary: \n"
153  << " - Min event: " << min_event_time_ << "\n"
154  << " - Max event: " << max_event_time_ << "\n"
155  << " - Avg event: " << average_event_time << "\n"
156  << " - Total job: " << total_job_time << "\n"
157  << " CPU Summary: \n"
158  << " - Min event: " << min_event_cpu_ << "\n"
159  << " - Max event: " << max_event_cpu_ << "\n"
160  << " - Avg event: " << average_event_cpu << "\n"
161  << " - Total job: " << total_job_cpu << "\n"
162  << " - Total event: " << total_event_cpu_ << "\n";
163 
164  if (report_summary_) {
165  Service<JobReport> reportSvc;
166 // std::map<std::string, double> reportData;
167  std::map<std::string, std::string> reportData;
168 
169  reportData.insert(std::make_pair("MinEventTime", d2str(min_event_time_)));
170  reportData.insert(std::make_pair("MaxEventTime", d2str(max_event_time_)));
171  reportData.insert(std::make_pair("AvgEventTime", d2str(average_event_time)));
172  reportData.insert(std::make_pair("TotalJobTime", d2str(total_job_time)));
173  reportData.insert(std::make_pair("MinEventCPU", d2str(min_event_cpu_)));
174  reportData.insert(std::make_pair("MaxEventCPU", d2str(max_event_cpu_)));
175  reportData.insert(std::make_pair("AvgEventCPU", d2str(average_event_cpu)));
176  reportData.insert(std::make_pair("TotalJobCPU", d2str(total_job_cpu)));
177  reportData.insert(std::make_pair("TotalEventCPU", d2str(total_event_cpu_)));
178 
179  reportSvc->reportPerformanceSummary("Timing", reportData);
180 // reportSvc->reportTimingInfo(reportData);
181  }
182  }
double curr_job_time_
Definition: Timing.h:54
double max_event_time_
Definition: Timing.h:66
bool report_summary_
Definition: Timing.h:61
static double getCPU()
Definition: Timing.cc:69
double curr_job_cpu_
Definition: Timing.h:55
double max_event_cpu_
Definition: Timing.h:67
double total_event_cpu_
Definition: Timing.h:59
int total_event_count_
Definition: Timing.h:70
static std::string d2str(double d)
Definition: Memory.cc:57
double min_event_cpu_
Definition: Timing.h:69
static double getTime()
double min_event_time_
Definition: Timing.h:68
void edm::service::Timing::postEventProcessing ( Event const &  e,
EventSetup const &   
)
private

Definition at line 190 of file Timing.cc.

References curr_event_, curr_event_cpu_, curr_event_time_, edm::EventID::event(), edm::service::getCPU(), edm::service::getTime(), max_event_cpu_, max_event_time_, min_event_cpu_, min_event_time_, edm::EventID::run(), summary_only_, total_event_count_, and total_event_cpu_.

Referenced by Timing().

190  {
193 
195 
196  if (not summary_only_) {
197  LogPrint("TimeEvent") // ChangeLog 3
198  << "TimeEvent> "
199  << curr_event_.event() << " "
200  << curr_event_.run() << " "
201  << curr_event_time_ << " "
202  << curr_event_cpu_ << " "
203  << total_event_cpu_;
204  }
205  if (total_event_count_ == 0) {
210  }
211 
217  }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
double max_event_time_
Definition: Timing.h:66
double curr_event_cpu_
Definition: Timing.h:57
static double getCPU()
Definition: Timing.cc:69
EventID curr_event_
Definition: Timing.h:53
double max_event_cpu_
Definition: Timing.h:67
double total_event_cpu_
Definition: Timing.h:59
int total_event_count_
Definition: Timing.h:70
double min_event_cpu_
Definition: Timing.h:69
static double getTime()
double min_event_time_
Definition: Timing.h:68
double curr_event_time_
Definition: Timing.h:56
void edm::service::Timing::postModule ( ModuleDescription const &  desc)
private

Definition at line 223 of file Timing.cc.

References curr_event_, curr_module_time_, edm::EventID::event(), edm::service::getTime(), edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), edm::EventID::run(), summary_only_, and matplotRender::t.

Referenced by Timing().

223  {
224  double t = getTime() - curr_module_time_;
225  //LogInfo("TimeModule")
226  if (not summary_only_) {
227  LogPrint("TimeModule") << "TimeModule> " // ChangeLog 4
228  << curr_event_.event() << " "
229  << curr_event_.run() << " "
230  << desc.moduleLabel() << " "
231  << desc.moduleName() << " "
232  << t;
233  }
234 
235  }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
EventID curr_event_
Definition: Timing.h:53
double curr_module_time_
Definition: Timing.h:58
static double getTime()
void edm::service::Timing::preEventProcessing ( EventID const &  iID,
Timestamp const &  iTime 
)
private

Definition at line 184 of file Timing.cc.

References curr_event_, curr_event_cpu_, curr_event_time_, edm::service::getCPU(), and edm::service::getTime().

Referenced by Timing().

184  {
185  curr_event_ = iID;
188  }
double curr_event_cpu_
Definition: Timing.h:57
static double getCPU()
Definition: Timing.cc:69
EventID curr_event_
Definition: Timing.h:53
static double getTime()
double curr_event_time_
Definition: Timing.h:56
void edm::service::Timing::preModule ( ModuleDescription const &  )
private

Definition at line 219 of file Timing.cc.

References curr_module_time_, and edm::service::getTime().

Referenced by Timing().

219  {
221  }
double curr_module_time_
Definition: Timing.h:58
static double getTime()

Member Data Documentation

EventID edm::service::Timing::curr_event_
private

Definition at line 53 of file Timing.h.

Referenced by postEventProcessing(), postModule(), and preEventProcessing().

double edm::service::Timing::curr_event_cpu_
private

Definition at line 57 of file Timing.h.

Referenced by postEventProcessing(), and preEventProcessing().

double edm::service::Timing::curr_event_time_
private

Definition at line 56 of file Timing.h.

Referenced by postEventProcessing(), and preEventProcessing().

double edm::service::Timing::curr_job_cpu_
private

Definition at line 55 of file Timing.h.

Referenced by postBeginJob(), and postEndJob().

double edm::service::Timing::curr_job_time_
private

Definition at line 54 of file Timing.h.

Referenced by postBeginJob(), and postEndJob().

double edm::service::Timing::curr_module_time_
private

Definition at line 58 of file Timing.h.

Referenced by postModule(), and preModule().

double edm::service::Timing::max_event_cpu_
private

Definition at line 67 of file Timing.h.

Referenced by postEndJob(), and postEventProcessing().

double edm::service::Timing::max_event_time_
private

Definition at line 66 of file Timing.h.

Referenced by postEndJob(), and postEventProcessing().

double edm::service::Timing::min_event_cpu_
private

Definition at line 69 of file Timing.h.

Referenced by postEndJob(), and postEventProcessing().

double edm::service::Timing::min_event_time_
private

Definition at line 68 of file Timing.h.

Referenced by postEndJob(), and postEventProcessing().

sigc::signal<void, ModuleDescription const&, double> edm::service::Timing::newMeasurementSignal

Definition at line 42 of file Timing.h.

bool edm::service::Timing::report_summary_
private

Definition at line 61 of file Timing.h.

Referenced by postEndJob().

bool edm::service::Timing::summary_only_
private

Definition at line 60 of file Timing.h.

Referenced by postBeginJob(), postEventProcessing(), postModule(), and Timing().

int edm::service::Timing::total_event_count_
private

Definition at line 70 of file Timing.h.

Referenced by postEndJob(), and postEventProcessing().

double edm::service::Timing::total_event_cpu_
private

Definition at line 59 of file Timing.h.

Referenced by postBeginJob(), postEndJob(), and postEventProcessing().