Skip to content

Timer

Utility timer for measuring elapsed time.

This class provides a simple mechanism for tracking time intervals using a steady clock. Typical usage includes measuring frame time, profiling sections of code, or retrieving a human-readable timestamp string.

Construction

Constructors


Timer()

Constructs a timer.

cpp
Timer::Timer(bool auto_start);
ParameterDescription
auto_startStarts timer immediately upon construction.

Functions

GetElapsedMilliseconds() double

Returns the elapsed time in milliseconds since the timer started.

cpp
double Timer::GetElapsedMilliseconds() const;

GetElapsedSeconds() double

Returns the elapsed time in seconds since the timer started.

cpp
double Timer::GetElapsedSeconds() const;

Start() void

Starts the timer.

cpp
void Timer::Start();

Timer::GetTimestamp() std::string

Returns the current local time as a formatted string.

The result is formatted as YYYY-MM-DD HH:MM:SS using the system's local timezone.

cpp
static std::string Timer::GetTimestamp();

Released under the MIT License.