CMS 3D CMS Logo

TimerService.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sched.h>
3 
8 
10  edm::ActivityRegistry& iAR) :
11  useCPUtime( ps.getUntrackedParameter<bool>("useCPUtime", true) ),
12  cpu_timer(useCPUtime),
13  is_bound_(false)
14 {
15  if (useCPUtime) {
17  if (is_bound_)
18  // the process is (now) bound to a single CPU, the call to clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...) is safe to use
19  edm::LogInfo("TimerService") << "this process is bound to CPU " << CPUAffinity::currentCpu();
20  else
21  // the process is NOT bound to a single CPU
22  edm::LogError("TimerService") << "this process is NOT bound to a single CPU, the results of the TimerService may be undefined";
23  }
24 
27 }
28 
30 {
31  if (useCPUtime and not is_bound_)
32  std::cout << "this process is NOT bound to a single CPU, the results of the TimerService may be undefined";
33  std::cout << "==========================================================\n";
34  std::cout << " TimerService Info:\n";
35  std::cout << " Used " << (useCPUtime ? "CPU" : "wall-clock") << "time for timing information\n";
36  std::cout << "==========================================================\n";
37  std::cout << std::flush;
38 }
39 
42  desc.addUntracked<bool>("useCPUtime",true);
43  descriptions.add("TimerService", desc);
44 }
45 
46 // fwk calls this method before a module is processed
48 {
49  cpu_timer.reset();
50  cpu_timer.start();
51 }
52 
53 // fwk calls this method after a module has been processed
55 {
56  cpu_timer.stop();
57  double time = cpu_timer.delta(); // in secs
58  newMeasurementSignal(iMod, time);
59 }
void postModule(const edm::ModuleDescription &iMod)
Definition: TimerService.cc:54
void preModule(const edm::ModuleDescription &iMod)
Definition: TimerService.cc:47
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void watchPostModule(PostModule::slot_type const &iSlot)
void watchPreModule(PreModule::slot_type const &iSlot)
TimerService(const edm::ParameterSet &, edm::ActivityRegistry &iAR)
Definition: TimerService.cc:9
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static int currentCpu()
Definition: CPUAffinity.cc:51
hlt::CPUTimer cpu_timer
Definition: TimerService.h:103
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TimerService.cc:40
sigc::signal< void, const edm::ModuleDescription &, double > newMeasurementSignal
Definition: TimerService.h:91
double delta() const
Definition: TimerService.h:68
static bool bindToCurrentCpu()
Definition: CPUAffinity.cc:78