API 4.4.1-2022-10-19-2c4045e59
For MATLAB, Python, Java, and C++ users
OpenSim::Stopwatch Class Reference

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

Public Member Functions

 Stopwatch ()
 This stores the start time as the current time. More...
 
void reset ()
 Reset the start time to the current time. More...
 
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()). More...
 

Static Public Member Functions

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

Detailed Description

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

Constructor & Destructor Documentation

◆ Stopwatch()

OpenSim::Stopwatch::Stopwatch ( )
inline

This stores the start time as the current time.

References reset().

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()).

Referenced by getElapsedTimeFormatted().

◆ 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.

◆ getElapsedTimeFormatted()

std::string OpenSim::Stopwatch::getElapsedTimeFormatted ( ) const
inline

This provides the elapsed time as a formatted string (using format()).

References formatNs(), and getElapsedTimeInNs().

◆ getElapsedTimeInNs()

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

Get elapsed time in nanoseconds.

See SimTK::realTimeInNs() for more information.

Referenced by getElapsedTimeFormatted().

◆ reset()

void OpenSim::Stopwatch::reset ( )
inline

Reset the start time to the current time.

Referenced by Stopwatch().


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