Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Timer.h File Reference

Provides high-resolution timing utilities based on Win32 performance counters. More...

#include "Raven/Core/Logging.h"
#include <Windows.h>
#include <chrono>
#include <string>
#include <vector>
#include <optional>
#include <algorithm>
#include <shared_mutex>

Classes

struct  Raven::TimerData
 Stores metadata for recorded timing sessions. More...
class  Raven::Timer
 High-resolution manual stopwatch. More...
class  Raven::ScopedTimer
 Scoped RAII timer that automatically records and stores timing data. More...
class  Raven::Time
 Global static time utility for frame-based timing. More...

Namespaces

namespace  Raven

Detailed Description

Provides high-resolution timing utilities based on Win32 performance counters.

Author
PhilikusHD

This file provides three tightly related timing utilities:

  1. Timer — a manual high-precision stopwatch (microsecond resolution) for ad hoc measurements.
  2. ScopedTimer — an RAII wrapper that measures a scope’s execution time and stores results in a static collection.
  3. Time — a global monotonic clock utility for frame timing and delta calculations.

Example usage

Manual Timer

// ... work ...
float ms = timer.ElapsedMillis();
High-resolution manual stopwatch.
Definition Timer.h:90
float ElapsedMillis() const
Returns the elapsed time since the last reset.
Definition Timer.h:120

ScopedTimer

{
Raven::ScopedTimer timer("LoadMesh", 10.0f);
LoadMesh();
} // Automatically logs if exceeded 10 ms
Scoped RAII timer that automatically records and stores timing data.
Definition Timer.h:143

Time

float current = Raven::Time::GetTime();
float delta = current - last;
last = current;
static float GetTime()
Returns the current time in seconds since engine initialization.
Definition Timer.h:202