MeteoIODoc  2.10.0
mio::Timer Class Reference

Detailed Description

Time code execution with at least 1 us resolution. The time resolution can be stored up to .1 ns resolution, but is measured to the following accuracy:

  • 1 us on Posix systems (Linux, osX, BSD);
  • 1 ns on Windows.
    Author
    Tuan Anh Nguyen (original implementation in popc), Mathias Bavay (port and rewrite for Alpine3D and MeteoIO)

#include <Timer.h>

Public Member Functions

 Timer ()
 Default constructor. Initialize internal variables. It does NOT start timing. More...
 
void start ()
 Start the timer. More...
 
void restart ()
 Reset and start the timer. More...
 
void stop ()
 Stop the timer. It can be restarted afterward, adding time to what was already timed. More...
 
void reset ()
 Reset the timer to zero. More...
 
double getElapsed () const
 Get total elapsed time. It returns the sum of all the elapsed time between all the start/stop sessions since the timer was created or the last call to reset. Time is in seconds with microsecond resolution. More...
 

Static Public Member Functions

static long double getCurrentTime ()
 Get the current time. More...
 

Protected Attributes

long double start_point
 
double elapsed
 
bool isRunning
 

Constructor & Destructor Documentation

◆ Timer()

mio::Timer::Timer ( )

Default constructor. Initialize internal variables. It does NOT start timing.

Member Function Documentation

◆ getCurrentTime()

long double mio::Timer::getCurrentTime ( )
static

Get the current time.

Returns
the current time as seconds since Unix Epoch

◆ getElapsed()

double mio::Timer::getElapsed ( ) const

Get total elapsed time. It returns the sum of all the elapsed time between all the start/stop sessions since the timer was created or the last call to reset. Time is in seconds with microsecond resolution.

◆ reset()

void mio::Timer::reset ( )

Reset the timer to zero.

◆ restart()

void mio::Timer::restart ( )

Reset and start the timer.

◆ start()

void mio::Timer::start ( )

Start the timer.

◆ stop()

void mio::Timer::stop ( )

Stop the timer. It can be restarted afterward, adding time to what was already timed.

Member Data Documentation

◆ elapsed

double mio::Timer::elapsed
protected

◆ isRunning

bool mio::Timer::isRunning
protected

◆ start_point

long double mio::Timer::start_point
protected

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