Raven Engine v0.1
Loading...
Searching...
No Matches
Timer.h File Reference

Provides a high resolution Timer, a ScopedTimer for RAII timing, and a Time utility for GLFW-based time queries. More...

#include "Raven/Core/Logging.h"
#include <chrono>
#include <cstddef>
#include <optional>
#include <utility>
#include "GLFW/glfw3.h"

Classes

struct  Raven::TimerData
 Holds the name, elapsed time, and threshold for a timer. More...
class  Raven::Timer
 A high-resolution timer class. More...
class  Raven::ScopedTimer
 A scoped timer class for automatic timing. More...
class  Raven::Time

Namespaces

namespace  Raven

Detailed Description

Provides a high resolution Timer, a ScopedTimer for RAII timing, and a Time utility for GLFW-based time queries.

Author
PhilikusHD

This file delivers three related timing utilities:

  1. Timer — manual high precision stopwatch (microsecond resolution) for ad hoc measurements.
  2. ScopedTimer — RAII wrapper that records elapsed time on destruction, storing results in a global list for later inspection or logging.
  3. Time — simple static access to the current GLFW time (in seconds) for driving frame based deltas.

Usage patterns:

  • Use Timer when you need start/stop control: cpp Timer t; // ... code to measure ... float ms = t.ElapsedMillis();
  • Use ScopedTimer to automatically record durations of a scope: cpp { ScopedTimer timer("MyTask", 5.0f (ms threshold)); // ... work ... } // on destruction, logs if greater than threshold and stores in TimerData list
  • Use Time::GetTime() each frame to compute delta and drive a Timestep.
Note
  • Timer measures in microseconds internally, but returns seconds or milliseconds as floats.
  • ScopedTimer collects every named timing in a static vector—inspect via ScopedTimer::GetTimers().
  • Time::GetTime() wraps glfwGetTime(), so it shares GLFW's epoch (time since initialization).