Skip to content

CPUTimer

Concrete implementation of the Timer class for CPU-based timing. More...

#include "Utils/Timers.h"

Inherits from Timer

Public Functions

Name
CPUTimer(std::string name)<br>Constructor.
~CPUTimer() override =default<br>Default destructor.
virtual doubleget()<br>Retrieves the elapsed time for the most recent interval.
virtual doublegetAverage()<br>Retrieves the average time over all measured intervals.
virtual unsigned intgetCounter() const<br>Retrieves the number of recorded intervals.
virtual voidreset()<br>Resets the timer, clearing all recorded data.
virtual voidstart(bool sync)<br>Starts the timer.
virtual voidstop(bool sync)<br>Stops the timer.

Additional inherited members

Public Functions inherited from Timer

Name
Timer() =default
Timer(double intervalSeconds, sol::protected_function callback, bool oneShot =false)
Timer(std::string name)<br>Constructor.
virtual~Timer() =default<br>Virtual destructor.
const std::string &getName() const<br>Retrieves the name of the timer.
voidtick(double dt)

Protected Attributes inherited from Timer

Name
unsigned intcounter <br>Number of recorded intervals.
std::stringname <br>Name of the timer.
GLuint64previousFrameQueryStart
doublepreviousFrameTimeStart <br>Start time of the previous frame.
GLuintquery <br>OpenGL query object for timing.
GLuintqueryStart
GLuintqueryStop <br>OpenGL query objects for timing.
doubletime <br>Time elapsed for the current interval.
doubletimeStart <br>Start time of the current interval.
doubletimeStop <br>Stop time of the current interval.
doubletimeTotal <br>Total accumulated time.

Friends inherited from Timer

Name
classChronos

Detailed Description

cpp
class CPUTimer;
class CPUTimer;

Concrete implementation of the Timer class for CPU-based timing.

The CPUTimer class measures execution time on the CPU and provides methods to retrieve elapsed and average times.

Public Functions Documentation

function CPUTimer

cpp
inline CPUTimer(
    std::string name
)
inline CPUTimer(
    std::string name
)

Constructor.

Parameters:

  • name Name of the timer.

function ~CPUTimer

cpp
~CPUTimer() override =default
~CPUTimer() override =default

Default destructor.

function get

cpp
inline virtual double get()
inline virtual double get()

Retrieves the elapsed time for the most recent interval.

Return: The elapsed time in seconds.

Reimplements: Timer::get

function getAverage

cpp
inline virtual double getAverage()
inline virtual double getAverage()

Retrieves the average time over all measured intervals.

Return: The average time in seconds.

Reimplements: Timer::getAverage

function getCounter

cpp
inline virtual unsigned int getCounter() const
inline virtual unsigned int getCounter() const

Retrieves the number of recorded intervals.

Return: The interval count.

Reimplements: Timer::getCounter

function reset

cpp
inline virtual void reset()
inline virtual void reset()

Resets the timer, clearing all recorded data.

Reimplements: Timer::reset

function start

cpp
inline virtual void start(
    bool sync
)
inline virtual void start(
    bool sync
)

Starts the timer.

Parameters:

  • sync Ignored in this implementation.

Reimplements: Timer::start

function stop

cpp
inline virtual void stop(
    bool sync
)
inline virtual void stop(
    bool sync
)

Stops the timer.

Parameters:

  • sync Ignored in this implementation.

Reimplements: Timer::stop


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