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

#include <Timer.h>

Public Member Functions

void start ()
 
double splittime (bool _save, bool _echo=true)
 
double stop (bool _echo=true)
 

Static Public Member Functions

static TimerGetTimer ()
 

Private Member Functions

double duration (timeval &tstart, timeval &tend)
 
 Timer ()
 
 Timer (const Timer &)
 
Timeroperator= (const Timer &)
 
 ~Timer ()
 

Private Attributes

timeval startTime
 
timeval lastTime
 

Detailed Description

Definition at line 14 of file Timer.h.

Constructor & Destructor Documentation

Timer::Timer ( )
inlineprivate

Definition at line 28 of file Timer.h.

28 { start(); }
void start()
Definition: Timer.h:41
Timer::Timer ( const Timer )
private
Timer::~Timer ( )
inlineprivate

Definition at line 32 of file Timer.h.

32 {;}

Member Function Documentation

double Timer::duration ( timeval &  tstart,
timeval &  tend 
)
inlineprivate

Definition at line 20 of file Timer.h.

21  {
22  long sec = tend.tv_sec - tstart.tv_sec;
23  long usec = tend.tv_usec - tstart.tv_usec;
24  double tdiff = sec + usec/1.0E+6;
25  return tdiff;
26  }
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
static Timer& Timer::GetTimer ( )
inlinestatic

Definition at line 35 of file Timer.h.

36  {
37  static Timer inst;
38  return inst;
39  }
Definition: Timer.h:14
Timer& Timer::operator= ( const Timer )
private
double Timer::splittime ( bool  _save,
bool  _echo = true 
)
inline

Definition at line 47 of file Timer.h.

48  {
49  timeval curTime;
50  gettimeofday(&curTime, NULL);
51 
52  double tdiff = duration(lastTime, curTime);
53  if(_save) lastTime = curTime;
54  if(_echo) printf("Time from last %.6f s\n", tdiff);
55  return tdiff;
56  }
timeval lastTime
Definition: Timer.h:18
double duration(timeval &tstart, timeval &tend)
Definition: Timer.h:20
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
int gettimeofday(struct timeval *, struct timezone *)
void Timer::start ( )
inline

Definition at line 41 of file Timer.h.

42  {
43  gettimeofday(&startTime, NULL);
45  }
timeval lastTime
Definition: Timer.h:18
timeval startTime
Definition: Timer.h:17
int gettimeofday(struct timeval *, struct timezone *)
double Timer::stop ( bool  _echo = true)
inline

Definition at line 58 of file Timer.h.

59  {
60  timeval curTime;
61  gettimeofday(&curTime, NULL);
62 
63  double tdiff = duration(startTime, curTime);
64  if(_echo) printf("Time from start %.6f s\n", tdiff);
65  return tdiff;
66  }
timeval startTime
Definition: Timer.h:17
double duration(timeval &tstart, timeval &tend)
Definition: Timer.h:20
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
int gettimeofday(struct timeval *, struct timezone *)

Member Data Documentation

timeval Timer::lastTime
private

Definition at line 18 of file Timer.h.

timeval Timer::startTime
private

Definition at line 17 of file Timer.h.


The documentation for this class was generated from the following file: