CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Attributes

TimerService Class Reference

#include <TimerService.h>

List of all members.

Public Member Functions

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

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 80 of file TimerService.h.


Constructor & Destructor Documentation

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

Definition at line 8 of file TimerService.cc.

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

                                                           :
  useCPUtime( ps.getUntrackedParameter<bool>("useCPUtime", true) ),
  cpu_timer(useCPUtime),
  is_bound_(false)
{
  if (useCPUtime) {
    is_bound_ = CPUAffinity::bindToCurrentCpu();
    if (is_bound_)
      // the process is (now) bound to a single CPU, the call to clock_gettime(CLOCK_THREAD_CPUTIME_ID, ...) is safe to use
      edm::LogInfo("TimerService") << "this process is bound to CPU " << CPUAffinity::currentCpu();
    else
      // the process is NOT bound to a single CPU
      edm::LogError("TimerService") << "this process is NOT bound to a single CPU, the results of the TimerService may be undefined";
  }

  iAR.watchPreModule(this, &TimerService::preModule);
  iAR.watchPostModule(this, &TimerService::postModule);
}
TimerService::~TimerService ( )

Definition at line 28 of file TimerService.cc.

References gather_cfg::cout, is_bound_, and useCPUtime.

{
  if (useCPUtime and not is_bound_)
    std::cout << "this process is NOT bound to a single CPU, the results of the TimerService may be undefined";
  std::cout << "==========================================================\n";
  std::cout << " TimerService Info:\n";
  std::cout << " Used " << (useCPUtime ? "CPU" : "wall-clock") << "time for timing information\n";
  std::cout << "==========================================================\n";
  std::cout << std::flush;
}

Member Function Documentation

void TimerService::postModule ( const edm::ModuleDescription iMod)

Definition at line 47 of file TimerService.cc.

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

Referenced by TimerService().

{
  cpu_timer.stop();
  double time = cpu_timer.delta();  // in secs
  newMeasurementSignal(iMod, time);
}
void TimerService::preModule ( const edm::ModuleDescription iMod)

Definition at line 40 of file TimerService.cc.

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

Referenced by TimerService().


Member Data Documentation

Definition at line 98 of file TimerService.h.

Referenced by postModule(), and preModule().

bool TimerService::is_bound_ [private]

Definition at line 101 of file TimerService.h.

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

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

Definition at line 86 of file TimerService.h.

Referenced by postModule().

bool TimerService::useCPUtime [private]

Definition at line 95 of file TimerService.h.

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