libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
ElapsedTimer Class Reference

Monotonic elapsed-time measurement using std::chrono::steady_clock. More...

#include <elapsedtimer.h>

Public Member Functions

 ElapsedTimer ()
 Constructs and starts the timer.
 
void start ()
 Records the current time as the start point.
 
int64_t restart ()
 Restarts the timer and returns the elapsed time since the previous start.
 
int64_t elapsed () const
 Returns milliseconds elapsed since start.
 
int64_t elapsedUs () const
 Returns microseconds elapsed since start.
 
int64_t elapsedNs () const
 Returns nanoseconds elapsed since start.
 
bool hasExpired (int64_t ms) const
 Returns true if the elapsed time is at least ms milliseconds.
 
bool isValid () const
 Returns true if the timer has been started and not invalidated.
 
void invalidate ()
 Invalidates the timer, marking it as not running.
 

Detailed Description

Monotonic elapsed-time measurement using std::chrono::steady_clock.

The timer starts automatically on construction. Call start() or restart() to reset. The timer can be invalidated to indicate "not running".

Member Function Documentation

◆ elapsed()

int64_t ElapsedTimer::elapsed ( ) const
inline

Returns milliseconds elapsed since start.

Returns
Elapsed time in milliseconds.

◆ elapsedNs()

int64_t ElapsedTimer::elapsedNs ( ) const
inline

Returns nanoseconds elapsed since start.

Returns
Elapsed time in nanoseconds.

◆ elapsedUs()

int64_t ElapsedTimer::elapsedUs ( ) const
inline

Returns microseconds elapsed since start.

Returns
Elapsed time in microseconds.

◆ hasExpired()

bool ElapsedTimer::hasExpired ( int64_t  ms) const
inline

Returns true if the elapsed time is at least ms milliseconds.

Parameters
msThe threshold in milliseconds.
Returns
True if elapsed >= ms.

◆ isValid()

bool ElapsedTimer::isValid ( ) const
inline

Returns true if the timer has been started and not invalidated.

Returns
True if valid.

◆ restart()

int64_t ElapsedTimer::restart ( )
inline

Restarts the timer and returns the elapsed time since the previous start.

Returns
Milliseconds elapsed since the previous start.

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