CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes
TimerService Class Reference

#include <TimerService.h>

Public Member Functions

void postModule (const edm::ModuleDescription &iMod)
 
void preModule (const edm::ModuleDescription &iMod)
 
 TimerService (const edm::ParameterSet &, edm::ActivityRegistry &iAR)
 
 ~TimerService ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Public Attributes

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

Private Attributes

hlt::CPUTimer cpu_timer
 
bool is_bound_
 
bool useCPUtime
 

Detailed Description

Description: Class accessing CPUTimer to record processing-time info per module (either CPU-time or wall-clock-time)

Original Author: Christos Leonidopoulos, March 2007

Definition at line 84 of file TimerService.h.

Constructor & Destructor Documentation

TimerService::TimerService ( const edm::ParameterSet ps,
edm::ActivityRegistry iAR 
)

Definition at line 9 of file TimerService.cc.

References CPUAffinity::bindToCurrentCpu(), CPUAffinity::currentCpu(), is_bound_, postModule(), preModule(), useCPUtime, edm::ActivityRegistry::watchPostModule(), and edm::ActivityRegistry::watchPreModule().

10  :
11  useCPUtime( ps.getUntrackedParameter<bool>("useCPUtime", true) ),
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 }
void postModule(const edm::ModuleDescription &iMod)
Definition: TimerService.cc:54
T getUntrackedParameter(std::string const &, T const &) const
void preModule(const edm::ModuleDescription &iMod)
Definition: TimerService.cc:47
void watchPostModule(PostModule::slot_type const &iSlot)
void watchPreModule(PreModule::slot_type const &iSlot)
static int currentCpu()
Definition: CPUAffinity.cc:51
hlt::CPUTimer cpu_timer
Definition: TimerService.h:103
static bool bindToCurrentCpu()
Definition: CPUAffinity.cc:78
TimerService::~TimerService ( )

Definition at line 29 of file TimerService.cc.

References gather_cfg::cout, is_bound_, and useCPUtime.

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 }

Member Function Documentation

void TimerService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 40 of file TimerService.cc.

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

40  {
42  desc.addUntracked<bool>("useCPUtime",true);
43  descriptions.add("TimerService", desc);
44 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void TimerService::postModule ( const edm::ModuleDescription iMod)

Definition at line 54 of file TimerService.cc.

References cpu_timer, hlt::CPUTimer::delta(), newMeasurementSignal, hlt::CPUTimer::stop(), and ntuplemaker::time.

Referenced by TimerService().

55 {
56  cpu_timer.stop();
57  double time = cpu_timer.delta(); // in secs
58  newMeasurementSignal(iMod, time);
59 }
hlt::CPUTimer cpu_timer
Definition: TimerService.h:103
sigc::signal< void, const edm::ModuleDescription &, double > newMeasurementSignal
Definition: TimerService.h:91
double delta() const
Definition: TimerService.h:68
void TimerService::preModule ( const edm::ModuleDescription iMod)

Definition at line 47 of file TimerService.cc.

References cpu_timer, hlt::CPUTimer::reset(), and hlt::CPUTimer::start().

Referenced by TimerService().

48 {
49  cpu_timer.reset();
50  cpu_timer.start();
51 }
hlt::CPUTimer cpu_timer
Definition: TimerService.h:103

Member Data Documentation

hlt::CPUTimer TimerService::cpu_timer
private

Definition at line 103 of file TimerService.h.

Referenced by postModule(), and preModule().

bool TimerService::is_bound_
private

Definition at line 106 of file TimerService.h.

Referenced by TimerService(), and ~TimerService().

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

Definition at line 91 of file TimerService.h.

Referenced by postModule(), and Timer::Timer().

bool TimerService::useCPUtime
private

Definition at line 100 of file TimerService.h.

Referenced by TimerService(), and ~TimerService().