CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TimerService.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sched.h>
3 
7 
10  useCPUtime( ps.getUntrackedParameter<bool>("useCPUtime", true) ),
11  cpu_timer(useCPUtime),
12  is_bound_(false)
13 {
14  if (useCPUtime) {
16  if (is_bound_)
17  // the process is (now) bound to a single CPU, the call to clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...) is safe to use
18  edm::LogInfo("TimerService") << "this process is bound to CPU " << CPUAffinity::currentCpu();
19  else
20  // the process is NOT bound to a single CPU
21  edm::LogError("TimerService") << "this process is NOT bound to a single CPU, the results of the TimerService may be undefined";
22  }
23 
26 }
27 
29 {
30  if (useCPUtime and not is_bound_)
31  std::cout << "this process is NOT bound to a single CPU, the results of the TimerService may be undefined";
32  std::cout << "==========================================================\n";
33  std::cout << " TimerService Info:\n";
34  std::cout << " Used " << (useCPUtime ? "CPU" : "wall-clock") << "time for timing information\n";
35  std::cout << "==========================================================\n";
36  std::cout << std::flush;
37 }
38 
39 // fwk calls this method before a module is processed
41 {
42  cpu_timer.reset();
43  cpu_timer.start();
44 }
45 
46 // fwk calls this method after a module has been processed
48 {
49  cpu_timer.stop();
50  double time = cpu_timer.delta(); // in secs
51  newMeasurementSignal(iMod, time);
52 }
void postModule(const edm::ModuleDescription &iMod)
Definition: TimerService.cc:47
void preModule(const edm::ModuleDescription &iMod)
Definition: TimerService.cc:40
void watchPostModule(PostModule::slot_type const &iSlot)
void watchPreModule(PreModule::slot_type const &iSlot)
TimerService(const edm::ParameterSet &, edm::ActivityRegistry &iAR)
Definition: TimerService.cc:8
static int currentCpu()
Definition: CPUAffinity.cc:51
hlt::CPUTimer cpu_timer
Definition: TimerService.h:98
sigc::signal< void, const edm::ModuleDescription &, double > newMeasurementSignal
Definition: TimerService.h:86
double delta() const
Definition: TimerService.h:64
tuple cout
Definition: gather_cfg.py:121
static bool bindToCurrentCpu()
Definition: CPUAffinity.cc:78