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

Constructor & Destructor Documentation

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

Definition at line 38 of file TimerService.h.

References reset().

38  :
40  {
41  reset();
42  }
#define CLOCK_THREAD_CPUTIME_ID
Definition: TimerService.h:31
const clockid_t timer_
Definition: TimerService.h:72
#define CLOCK_REALTIME
Definition: TimerService.h:28

Member Function Documentation

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

Definition at line 64 of file TimerService.h.

References start_, and stop_.

Referenced by TimerService::postModule().

64  {
65  if (stop_.tv_nsec > start_.tv_nsec)
66  return (double) (stop_.tv_sec - start_.tv_sec) + (double) (stop_.tv_nsec - start_.tv_nsec) / (double) 1e9;
67  else
68  return (double) (stop_.tv_sec - start_.tv_sec) - (double) (start_.tv_nsec - stop_.tv_nsec) / (double) 1e9;
69  }
timespec start_
Definition: TimerService.h:73
timespec stop_
Definition: TimerService.h:74
void hlt::CPUTimer::reset ( void  )
inline

Definition at line 44 of file TimerService.h.

References start_, and stop_.

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

44  {
45  start_.tv_sec = 0;
46  start_.tv_nsec = 0;
47  stop_.tv_sec = 0;
48  stop_.tv_nsec = 0;
49  }
timespec start_
Definition: TimerService.h:73
timespec stop_
Definition: TimerService.h:74
void hlt::CPUTimer::start ( void  )
inline

Definition at line 51 of file TimerService.h.

References start_, and timer_.

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

51  {
52 #ifdef __linux
53  clock_gettime(timer_, & start_);
54 #endif
55  }
timespec start_
Definition: TimerService.h:73
const clockid_t timer_
Definition: TimerService.h:72
void hlt::CPUTimer::stop ( )
inline

Definition at line 57 of file TimerService.h.

References stop_, and timer_.

Referenced by TimerService::postModule().

57  {
58 #ifdef __linux
59  clock_gettime(timer_, & stop_);
60 #endif
61  }
timespec stop_
Definition: TimerService.h:74
const clockid_t timer_
Definition: TimerService.h:72

Member Data Documentation

timespec hlt::CPUTimer::start_
private

Definition at line 73 of file TimerService.h.

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

timespec hlt::CPUTimer::stop_
private

Definition at line 74 of file TimerService.h.

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

const clockid_t hlt::CPUTimer::timer_
private

Definition at line 72 of file TimerService.h.

Referenced by start(), and stop().