Skip to content

Timer

Utility class for measuring elapsed time.

The Timer 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()

cpp
vglx::Timer::Timer(bool auto_start)
ParameterDescription
auto_startIf true, the timer starts immediately upon construction.

Constructs a Timer object.

Functions

GetElapsedMilliseconds() double

cpp
double vglx::Timer::GetElapsedMilliseconds() const

Returns the elapsed time in milliseconds since the timer started.

GetElapsedSeconds() double

cpp
double vglx::Timer::GetElapsedSeconds() const

Returns the elapsed time in seconds since the timer started.

Start() void

cpp
void vglx::Timer::Start()

Starts the timer.

Timer::GetTimestamp() std::string

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

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.

Released under the MIT License.