AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::utilities::Timer Class Reference

A simple Timer class to measure execution time. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/core/utilities/Timer.hpp>

Public Member Functions

 Timer (bool startRunning=false)
 Default constructor. More...
 
void start ()
 Starts the timer.Sets the start time of this Timer instance. More...
 
void stop ()
 Stops the timer. Sets the end time of this Timer instance. More...
 
double elapsed ()
 Returns the elapsed time in seconds. More...
 
double elapsedTimeInSec ()
 Returns the elapsed time in seconds. More...
 
double elapsedTimeInMilliSec ()
 Returns the elapsed time in milliseconds. More...
 
double elapsedTimeInMicroSec ()
 Returns the elapsed time in microseconds. More...
 
void reset ()
 Resets the timer. More...
 

Detailed Description

A simple Timer class to measure execution time.

Note
We might want to extend the functionality of the timer class by making HighPrecisionTimer a template parameter. API requirements for HighPrecisionTimer class – must be default constructible – timing functions: void start() void stop() void reset() – elapsed time functions: double elapsedTimeInSec() double elapsedTimeInMilliSec() double elapsedTimeInMicroSec()
We might want to add support for pausing and resuming the timer while accumulating the time differences

Example Usage:

utilities::Timer t;
t.start();
// code to measure its execution time
t.stop();
std::cout << "Elapsed Time: << t.elapsed() << std::endl;
t.reset();

Constructor & Destructor Documentation

◆ Timer()

axom::utilities::Timer::Timer ( bool  startRunning = false)
inline

Default constructor.

Parameters
startRunningIndicates whether to start the timer during construction (default is false)

References start().

Member Function Documentation

◆ start()

void axom::utilities::Timer::start ( )
inline

Starts the timer.Sets the start time of this Timer instance.

◆ stop()

void axom::utilities::Timer::stop ( )
inline

Stops the timer. Sets the end time of this Timer instance.

◆ elapsed()

double axom::utilities::Timer::elapsed ( )
inline

Returns the elapsed time in seconds.

Returns
t the elapsed time in seconds.

References elapsedTimeInSec().

◆ elapsedTimeInSec()

double axom::utilities::Timer::elapsedTimeInSec ( )
inline

Returns the elapsed time in seconds.

Returns
t the elapsed time in seconds.

References stop().

◆ elapsedTimeInMilliSec()

double axom::utilities::Timer::elapsedTimeInMilliSec ( )
inline

Returns the elapsed time in milliseconds.

Returns
t the elapsed time in milliseconds.

References stop().

◆ elapsedTimeInMicroSec()

double axom::utilities::Timer::elapsedTimeInMicroSec ( )
inline

Returns the elapsed time in microseconds.

Returns
t the elapsed time in microseconds.

References stop().

◆ reset()

void axom::utilities::Timer::reset ( )
inline

Resets the timer.

Postcondition
this->elapsed()==0.0

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