Skip to content

Statistics

Static utility class for tracking performance metrics such as FPS, timers, and frame details. More...

#include "Utils/Statistics.h"

Public Classes

Name
classFrame <br>Nested class for frame-specific statistics.
classGPU <br>Nested class for GPU-specific statistics.

Public Functions

Name
Statistics() =delete<br>Deleted constructor to prevent instantiation.
~Statistics() =delete<br>Deleted destructor to prevent destruction.
voidstartGPUTimer(const std::string & name)<br>Starts a GPU timer for the given name.
voidstartTimer(const std::string & name)<br>Starts a timer with the given name.
voidstopGPUTimer(const std::string & name)<br>Stops a GPU timer for the given name.
voidstopTimer(const std::string & name)<br>Stops a timer with the given name.
voidupdate()<br>Updates the internal state of the statistics system.

Public Attributes

Name
std::map< std::string, TimerPtr >CPUTimers <br>Map of all active timers.
floatDeltaTime <br>Time elapsed between frames, in seconds.
floatFPS <br>Current frames per second.
std::map< std::string, TimerPtr >GPUTimers

Detailed Description

cpp
class Statistics;
class Statistics;

Static utility class for tracking performance metrics such as FPS, timers, and frame details.

The [Statistics](/cpp-api-reference/classes/classStatistics) class provides static members and methods to track and manage application performance metrics. It includes nested classes for frame-specific and GPU-specific statistics.

Public Functions Documentation

function Statistics

cpp
Statistics() =delete
Statistics() =delete

Deleted constructor to prevent instantiation.

function ~Statistics

cpp
~Statistics() =delete
~Statistics() =delete

Deleted destructor to prevent destruction.

function startGPUTimer

cpp
static void startGPUTimer(
    const std::string & name
)
static void startGPUTimer(
    const std::string & name
)

Starts a GPU timer for the given name.

Parameters:

  • name The name of the timer to start.

If a timer with the specified name does not exist, it is created and started.

function startTimer

cpp
static void startTimer(
    const std::string & name
)
static void startTimer(
    const std::string & name
)

Starts a timer with the given name.

Parameters:

  • name The name of the timer to start.
  • name The name of the timer to start.

Starts a CPU timer for the given name.

If a timer with the specified name does not exist, it is created and started.

function stopGPUTimer

cpp
static void stopGPUTimer(
    const std::string & name
)
static void stopGPUTimer(
    const std::string & name
)

Stops a GPU timer for the given name.

Parameters:

  • name The name of the timer to stop.

If a timer with the specified name exists, it is stopped.

function stopTimer

cpp
static void stopTimer(
    const std::string & name
)
static void stopTimer(
    const std::string & name
)

Stops a timer with the given name.

Parameters:

  • name The name of the timer to stop.
  • name The name of the timer to stop.

Stops a CPU timer for the given name.

If a timer with the specified name exists, it is stopped.

function update

cpp
static void update()
static void update()

Updates the internal state of the statistics system.

Updates statistics including frame ID, FPS, and GPU memory usage.

This function increments the frame ID and updates FPS and DeltaTime values using ImGui's IO metrics. Additionally, it checks for GPU memory info support and retrieves memory usage details if the necessary OpenGL extension is available.

Public Attributes Documentation

variable CPUTimers

cpp
static std::map< std::string, TimerPtr > CPUTimers = {};
static std::map< std::string, TimerPtr > CPUTimers = {};

Map of all active timers.

Each timer is identified by a string name.

variable DeltaTime

cpp
static float DeltaTime = 0.0f;
static float DeltaTime = 0.0f;

Time elapsed between frames, in seconds.

variable FPS

cpp
static float FPS = 0.0f;
static float FPS = 0.0f;

Current frames per second.

variable GPUTimers

cpp
static std::map< std::string, TimerPtr > GPUTimers = {};
static std::map< std::string, TimerPtr > GPUTimers = {};

Updated on 2025-05-31 at 12:55:30 +0000