A simple stop watch. More...

#include <dune/common/timer.hh>

List of all members.

Public Member Functions

 Timer (bool startImmediately=true) throw (TimerError)
 A new timer, create and reset.
void reset () throw (TimerError)
 Reset timer while keeping the running/stopped state.
void start () throw (TimerError)
 Start the timer and continue measurement if it is not running. Otherwise do nothing.
double elapsed () const throw (TimerError)
 Get elapsed user-time from last reset until now/last stop in seconds.
double lastElapsed () const throw (TimerError)
 Get elapsed user-time from last start until now/last stop in seconds.
double stop () throw (TimerError)
 Stop the timer and return elapsed().

Detailed Description

A simple stop watch.

This class reports the elapsed user-time, i.e. time spent computing, after the last call to Timer::reset(). The results are seconds and fractional seconds. Note that the resolution of the timing depends on your OS kernel which should be somewhere in the milisecond range.

The class is basically a wrapper for the libc-function getrusage()


Constructor & Destructor Documentation

Dune::Timer::Timer ( bool  startImmediately = true  )  throw (TimerError) [inline]

A new timer, create and reset.

Parameters:
startImmediately If true (default) the timer starts counting immediately

References reset().


Member Function Documentation

double Dune::Timer::elapsed (  )  const throw (TimerError) [inline]

Get elapsed user-time from last reset until now/last stop in seconds.

References lastElapsed().

Referenced by stop().

double Dune::Timer::lastElapsed (  )  const throw (TimerError) [inline]

Get elapsed user-time from last start until now/last stop in seconds.

Referenced by elapsed(), and stop().

void Dune::Timer::reset (  )  throw (TimerError) [inline]

Reset timer while keeping the running/stopped state.

Referenced by Timer().

void Dune::Timer::start (  )  throw (TimerError) [inline]

Start the timer and continue measurement if it is not running. Otherwise do nothing.

double Dune::Timer::stop (  )  throw (TimerError) [inline]

Stop the timer and return elapsed().

References elapsed(), and lastElapsed().


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

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].