CARMA C++
carma::util::StopWatch Class Reference

Class for determining the elapsed wall-clock or CPU time between two events. More...

#include <carma/util/StopWatch.h>

Public Types

enum  ClockType { WALL_CLOCK = 0, CPU_TIME = 1 }
 enumeration for clock type More...
 

Public Member Functions

double getCumulativeElapsedTime (bool reset=false)
 get the the sum of the time intervals between each start and stop pair More...
 
double getElapsedTime () const
 get the time interval in seconds between the last start() and stop() More...
 
bool isRunning () const
 is the watch running? More...
 
void start ()
 start the watch More...
 
void stop ()
 stop the watch More...
 
 StopWatch ()
 constructor More...
 
 StopWatch (ClockType type)
 constructor More...
 
 StopWatch (const ::std::string &name)
 constructor More...
 
 StopWatch (ClockType type, const ::std::string &name)
 constructor More...
 
 ~StopWatch ()
 destructor, does nothing More...
 

Protected Attributes

double cumulativeElapsedTime_
 
double elapsedTime_
 
const ::std::string name_
 
bool running_
 
struct timespec scratchTimeSpec_
 
double startTime_
 
const ClockType type_
 

Detailed Description

Class for determining the elapsed wall-clock or CPU time between two events.

Precision of a few clock ticks for a single start()/stop() event pair on a lightly loaded machine

Definition at line 22 of file StopWatch.h.

Member Enumeration Documentation

enumeration for clock type

Definition at line 27 of file StopWatch.h.

Constructor & Destructor Documentation

carma::util::StopWatch::StopWatch ( )
explicit

constructor

carma::util::StopWatch::StopWatch ( ClockType  type)
explicit

constructor

carma::util::StopWatch::StopWatch ( const ::std::string &  name)
explicit

constructor

carma::util::StopWatch::StopWatch ( ClockType  type,
const ::std::string &  name 
)

constructor

carma::util::StopWatch::~StopWatch ( )

destructor, does nothing

Member Function Documentation

double carma::util::StopWatch::getCumulativeElapsedTime ( bool  reset = false)

get the the sum of the time intervals between each start and stop pair

double carma::util::StopWatch::getElapsedTime ( ) const

get the time interval in seconds between the last start() and stop()

bool carma::util::StopWatch::isRunning ( ) const

is the watch running?

void carma::util::StopWatch::start ( )

start the watch

Exceptions
IllegalStateExceptionif the watch is already running
void carma::util::StopWatch::stop ( )

stop the watch

Exceptions
IllegalStateExceptionif the watch is not running

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