QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
Quasar::Timer Class Reference

High-resolution (steady) timer that measures the time elapsed since it was created or last reset. More...

#include <quasar/core/Timer.h>

Public Types

using Clock = std::chrono::steady_clock
 Clock used by the timer, monotonic with nanosecond resolution.

Public Member Functions

 Timer ()
 Creates a timer that starts measuring right away.
void Reset ()
 Resets the timer to zero.
double ElapsedSeconds () const
 Returns the time elapsed since the timer was created or last reset, in seconds.
double ElapsedMilliseconds () const
 Returns the time elapsed since the timer was created or last reset, in milliseconds.

Detailed Description

High-resolution (steady) timer that measures the time elapsed since it was created or last reset.

It relies on a monotonic clock, so changes to the system time do not affect it.

Timer timer; LoadScene(); double ms = timer.ElapsedMilliseconds();

Member Typedef Documentation

◆ Clock

using Quasar::Timer::Clock = std::chrono::steady_clock

Clock used by the timer, monotonic with nanosecond resolution.

std::chrono::high_resolution_clock is not used on purpose: it is an alias whose target depends on the standard library, and with libstdc++ it is the system clock, which is not monotonic.

Member Function Documentation

◆ ElapsedSeconds()

double Quasar::Timer::ElapsedSeconds ( ) const

Returns the time elapsed since the timer was created or last reset, in seconds.

Returns
The elapsed time in seconds.

◆ ElapsedMilliseconds()

double Quasar::Timer::ElapsedMilliseconds ( ) const

Returns the time elapsed since the timer was created or last reset, in milliseconds.

Returns
The elapsed time in milliseconds.

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