OpenSim Moco  0.4.0
Public Member Functions | Static Public Member Functions | List of all members
OpenSim::Stopwatch Class Reference

Description

Record and report elapsed real time ("clock" or "wall" time) in seconds.

#include <Moco/Moco/MocoUtilities.h>

Public Member Functions

 Stopwatch ()
 This stores the start time as the current time.
 
void reset ()
 Reset the start time to the current time.
 
double getElapsedTime () const
 Return the amount of time that has elapsed since this object was constructed or since reset() has been called. More...
 
long long getElapsedTimeInNs () const
 Get elapsed time in nanoseconds. More...
 
std::string getElapsedTimeFormatted () const
 This provides the elapsed time as a formatted string (using format()).
 

Static Public Member Functions

static std::string formatNs (const long long &nanoseconds)
 Format the provided elapsed time in nanoseconds into a string. More...
 

Member Function Documentation

◆ formatNs()

static std::string OpenSim::Stopwatch::formatNs ( const long long &  nanoseconds)
inlinestatic

Format the provided elapsed time in nanoseconds into a string.

The time may be converted into seconds, milliseconds, or microseconds. Additionally, if the time is greater or equal to 60 seconds, the time in hours and/or minutes is also added to the string. Usually, you can call getElapsedTimeFormatted() instead of calling this function directly. If you call this function directly, use getElapsedTimeInNs() to get a time in nanoseconds (rather than getElapsedTime()).

◆ getElapsedTime()

double OpenSim::Stopwatch::getElapsedTime ( ) const
inline

Return the amount of time that has elapsed since this object was constructed or since reset() has been called.

◆ getElapsedTimeInNs()

long long OpenSim::Stopwatch::getElapsedTimeInNs ( ) const
inline

Get elapsed time in nanoseconds.

See SimTK::realTimeInNs() for more information.


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