Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
Public Member Functions | Protected Attributes | List of all members
kome::core::Timer Class Reference

timer class More...

#include <Timer.h>

Public Member Functions

 Timer ()
 constructor
 
virtual ~Timer ()
 destructor
 
void reset ()
 resets timer
 
void start ()
 starts timer
 
double stop ()
 stops timer More...
 
double getTime ()
 gets time More...
 
double getTotalTime ()
 gets total time More...
 

Protected Attributes

clock_t m_start
 
double m_total
 
bool m_stopped
 

Detailed Description

timer class

Definition at line 26 of file Timer.h.

Member Function Documentation

double kome::core::Timer::getTime ( )

gets time

Returns
time

Definition at line 67 of file Timer.cpp.

67  {
68  // get time
69  double t = 0.0;
70 
71  if( !m_stopped ) {
72  // current
73  clock_t current = std::clock();
74 
75  // time
76  t = (double)( current - m_start ) / (double)( CLOCKS_PER_SEC );
77  }
78 
79  return t;
80 }
clock_t m_start
Definition: Timer.h:42
bool m_stopped
Definition: Timer.h:48
double kome::core::Timer::getTotalTime ( )

gets total time

Returns
total time

Definition at line 83 of file Timer.cpp.

83  {
84  double t = m_total;
85  t += getTime();
86  return t;
87 }
double getTime()
gets time
Definition: Timer.cpp:67
double m_total
Definition: Timer.h:45

Here is the call graph for this function:

double kome::core::Timer::stop ( )

stops timer

Returns
lap time

Definition at line 52 of file Timer.cpp.

52  {
53  // total time
54  const double t = getTime();
55  m_total += getTime();
56 
57  // set start time
58  m_start = std::clock();
59 
60  // stopped
61  m_stopped = true;
62 
63  return t;
64 }
double getTime()
gets time
Definition: Timer.cpp:67
double m_total
Definition: Timer.h:45
clock_t m_start
Definition: Timer.h:42
bool m_stopped
Definition: Timer.h:48

Here is the call graph for this function:

Member Data Documentation

clock_t kome::core::Timer::m_start
protected

start time

Definition at line 42 of file Timer.h.

bool kome::core::Timer::m_stopped
protected

stopped

Definition at line 48 of file Timer.h.

double kome::core::Timer::m_total
protected

total time

Definition at line 45 of file Timer.h.


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