CMS 3D CMS Logo

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

#include <TimerService.h>

Public Member Functions

 CPUTimer (bool cpu=true)
 
double delta () const
 
void reset ()
 
void start ()
 
void stop ()
 

Private Attributes

timespec start_
 
timespec stop_
 
const clockid_t timer_
 

Detailed Description

Definition at line 40 of file TimerService.h.

Constructor & Destructor Documentation

hlt::CPUTimer::CPUTimer ( bool  cpu = true)
inlineexplicit

Definition at line 42 of file TimerService.h.

References reset().

42  :
44  {
45  reset();
46  }
#define CLOCK_THREAD_CPUTIME_ID
Definition: TimerService.h:35
const clockid_t timer_
Definition: TimerService.h:76
#define CLOCK_REALTIME
Definition: TimerService.h:32

Member Function Documentation

double hlt::CPUTimer::delta ( ) const
inline

Definition at line 68 of file TimerService.h.

References start_, and stop_.

Referenced by TimerService::postModule().

68  {
69  if (stop_.tv_nsec > start_.tv_nsec)
70  return (double) (stop_.tv_sec - start_.tv_sec) + (double) (stop_.tv_nsec - start_.tv_nsec) / (double) 1e9;
71  else
72  return (double) (stop_.tv_sec - start_.tv_sec) - (double) (start_.tv_nsec - stop_.tv_nsec) / (double) 1e9;
73  }
timespec start_
Definition: TimerService.h:77
timespec stop_
Definition: TimerService.h:78
void hlt::CPUTimer::reset ( void  )
inline

Definition at line 48 of file TimerService.h.

References start_, and stop_.

Referenced by CPUTimer(), and TimerService::preModule().

48  {
49  start_.tv_sec = 0;
50  start_.tv_nsec = 0;
51  stop_.tv_sec = 0;
52  stop_.tv_nsec = 0;
53  }
timespec start_
Definition: TimerService.h:77
timespec stop_
Definition: TimerService.h:78
void hlt::CPUTimer::start ( void  )
inline

Definition at line 55 of file TimerService.h.

References start_, and timer_.

Referenced by progressbar.ProgressBar::__next__(), and TimerService::preModule().

55  {
56 #ifdef __linux
57  clock_gettime(timer_, & start_);
58 #endif
59  }
timespec start_
Definition: TimerService.h:77
const clockid_t timer_
Definition: TimerService.h:76
void hlt::CPUTimer::stop ( )
inline

Definition at line 61 of file TimerService.h.

References stop_, and timer_.

Referenced by TimerService::postModule().

61  {
62 #ifdef __linux
63  clock_gettime(timer_, & stop_);
64 #endif
65  }
timespec stop_
Definition: TimerService.h:78
const clockid_t timer_
Definition: TimerService.h:76

Member Data Documentation

timespec hlt::CPUTimer::start_
private

Definition at line 77 of file TimerService.h.

Referenced by delta(), reset(), and start().

timespec hlt::CPUTimer::stop_
private

Definition at line 78 of file TimerService.h.

Referenced by delta(), reset(), and stop().

const clockid_t hlt::CPUTimer::timer_
private

Definition at line 76 of file TimerService.h.

Referenced by start(), and stop().