Timer
Abstract base class for measuring execution time and performance metrics. More...
#include "Scripting/Timer.h"
Inherited by CPUTimer, GPUTimer
Public Functions
| 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. |
| virtual double | get() =0<br>Retrieves the elapsed time for the most recent interval. |
| virtual double | getAverage() =0<br>Retrieves the average time over all measured intervals. |
| virtual unsigned int | getCounter() const =0<br>Retrieves the number of recorded intervals. |
| const std::string & | getName() const<br>Retrieves the name of the timer. |
| virtual void | reset() =0<br>Resets the timer, clearing all recorded data. |
| virtual void | start(bool sync =false) =0<br>Starts the timer. |
| virtual void | stop(bool sync =false) =0<br>Stops the timer. |
| void | tick(double dt) |
Protected Attributes
| Name | |
|---|---|
| unsigned int | counter <br>Number of recorded intervals. |
| std::string | name <br>Name of the timer. |
| GLuint64 | previousFrameQueryStart |
| double | previousFrameTimeStart <br>Start time of the previous frame. |
| GLuint | query <br>OpenGL query object for timing. |
| GLuint | queryStart |
| GLuint | queryStop <br>OpenGL query objects for timing. |
| double | time <br>Time elapsed for the current interval. |
| double | timeStart <br>Start time of the current interval. |
| double | timeStop <br>Stop time of the current interval. |
| double | timeTotal <br>Total accumulated time. |
Friends
| Name | |
|---|---|
| class | Chronos |
Detailed Description
class Timer;class Timer;Abstract base class for measuring execution time and performance metrics.
The Timer class provides a generic interface for timing operations. Derived classes must implement methods for starting, stopping, and retrieving timing information.
Public Functions Documentation
function Timer
Timer() =defaultTimer() =defaultfunction Timer
inline Timer(
double intervalSeconds,
sol::protected_function callback,
bool oneShot =false
)inline Timer(
double intervalSeconds,
sol::protected_function callback,
bool oneShot =false
)function Timer
inline Timer(
std::string name
)inline Timer(
std::string name
)Constructor.
Parameters:
- name Name of the timer.
function ~Timer
virtual ~Timer() =defaultvirtual ~Timer() =defaultVirtual destructor.
function get
virtual double get() =0virtual double get() =0Retrieves the elapsed time for the most recent interval.
Return: The elapsed time in seconds.
Reimplemented by: CPUTimer::get, GPUTimer::get
function getAverage
virtual double getAverage() =0virtual double getAverage() =0Retrieves the average time over all measured intervals.
Return: The average time in seconds.
Reimplemented by: CPUTimer::getAverage, GPUTimer::getAverage
function getCounter
virtual unsigned int getCounter() const =0virtual unsigned int getCounter() const =0Retrieves the number of recorded intervals.
Return: The interval count.
Reimplemented by: CPUTimer::getCounter, GPUTimer::getCounter
function getName
inline const std::string & getName() constinline const std::string & getName() constRetrieves the name of the timer.
Return: A reference to the timer name.
function reset
virtual void reset() =0virtual void reset() =0Resets the timer, clearing all recorded data.
Reimplemented by: CPUTimer::reset, GPUTimer::reset
function start
virtual void start(
bool sync =false
) =0virtual void start(
bool sync =false
) =0Starts the timer.
Parameters:
- sync Whether to synchronize with external operations before starting.
Reimplemented by: CPUTimer::start, GPUTimer::start
function stop
virtual void stop(
bool sync =false
) =0virtual void stop(
bool sync =false
) =0Stops the timer.
Parameters:
- sync Whether to synchronize with external operations before stopping.
Reimplemented by: CPUTimer::stop, GPUTimer::stop
function tick
inline void tick(
double dt
)inline void tick(
double dt
)Parameters:
- dt in seconds
Protected Attributes Documentation
variable counter
unsigned int counter {0};unsigned int counter {0};Number of recorded intervals.
variable name
std::string name;std::string name;Name of the timer.
variable previousFrameQueryStart
GLuint64 previousFrameQueryStart {0};GLuint64 previousFrameQueryStart {0};variable previousFrameTimeStart
double previousFrameTimeStart {0};double previousFrameTimeStart {0};Start time of the previous frame.
variable query
GLuint query {0};GLuint query {0};OpenGL query object for timing.
variable queryStart
GLuint queryStart {0};GLuint queryStart {0};variable queryStop
GLuint queryStop {0};GLuint queryStop {0};OpenGL query objects for timing.
variable time
double time {0};double time {0};Time elapsed for the current interval.
variable timeStart
double timeStart {0};double timeStart {0};Start time of the current interval.
variable timeStop
double timeStop {0};double timeStop {0};Stop time of the current interval.
variable timeTotal
double timeTotal {0};double timeTotal {0};Total accumulated time.
Friends
friend Chronos
friend class Chronos(
Chronos
);friend class Chronos(
Chronos
);Updated on 2026-05-21 at 15:39:35 +0000