Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Raven::ScopedTimer Class Reference

Scoped RAII timer that automatically records and stores timing data. More...

#include <Timer.h>

Public Member Functions

CORE_API ScopedTimer (std::string name, std::optional< float > threshold=std::nullopt)
 Constructs a ScopedTimer for the current scope.
CORE_API ScopedTimer (const ScopedTimer &)=delete
CORE_API ScopedTimeroperator= (const ScopedTimer &)=delete
CORE_API ScopedTimer (ScopedTimer &&)=delete
CORE_API ScopedTimeroperator= (ScopedTimer &&)=delete
CORE_API ~ScopedTimer ()
 Destroys the timer and records its elapsed time.

Static Public Member Functions

static CORE_API const std::vector< TimerData > & GetTimers ()
 Retrieves all stored timers.
static CORE_API void Reset ()
 Clears all stored timer data.

Detailed Description

Scoped RAII timer that automatically records and stores timing data.

On destruction, the measured time is appended to a static collection for later inspection (accessible via ScopedTimer::GetTimers()), and optionally logged if a threshold is exceeded.

Constructor & Destructor Documentation

◆ ScopedTimer() [1/3]

Raven::ScopedTimer::ScopedTimer ( std::string name,
std::optional< float > threshold = std::nullopt )
explicit

Constructs a ScopedTimer for the current scope.

Parameters
nameUnique name for identifying the timer.
thresholdOptional threshold (ms) for warning logs.

◆ ScopedTimer() [2/3]

CORE_API Raven::ScopedTimer::ScopedTimer ( const ScopedTimer & )
delete

◆ ScopedTimer() [3/3]

CORE_API Raven::ScopedTimer::ScopedTimer ( ScopedTimer && )
delete

◆ ~ScopedTimer()

Raven::ScopedTimer::~ScopedTimer ( )

Destroys the timer and records its elapsed time.

If a threshold was provided, a warning is logged when it's exceeded. Results are stored in a static vector for later retrieval.

Member Function Documentation

◆ GetTimers()

const std::vector< TimerData > & Raven::ScopedTimer::GetTimers ( )
staticnodiscard

Retrieves all stored timers.

Returns
Const reference to the internal list of timers.

◆ operator=() [1/2]

CORE_API ScopedTimer & Raven::ScopedTimer::operator= ( const ScopedTimer & )
delete

◆ operator=() [2/2]

CORE_API ScopedTimer & Raven::ScopedTimer::operator= ( ScopedTimer && )
delete

◆ Reset()

void Raven::ScopedTimer::Reset ( )
static

Clears all stored timer data.


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