Kanzi 3.9.10
kanzi::FrameTimeQueue Class Reference

Helper class for calculating the frame rate. More...

#include <kanzi/core.ui/util/frame_time_queue.hpp>

Public Member Functions

 FrameTimeQueue ()
 Constructor.
 
KZ_NO_DISCARD float getFPS () const
 Returns the current FPS.
 
void update (chrono::nanoseconds frameDuration)
 Updates the frame time queue with a new frame duration.
 

Static Public Attributes

static const size_t MeasurementBufferSize
 The maximum size of the measurement window. Oldest frame duration samples that don't fit to the buffer are not included in the reported FPS.
 
static const chrono::milliseconds MeasurementWindowWidth
 The maximum duration of the measurement window. Frame duration samples that are older than this are not included in the reported FPS.
 

Protected Attributes

size_t m_firstFrame
 Frame time queue front index.
 
float m_fps
 Frame rate cache.
 
size_t m_frameCount
 Frame time queue size.
 
array< chrono::nanoseconds, MeasurementBufferSizem_frames
 Frame time queue data.
 
chrono::nanoseconds m_totalTime
 Frame time queue content sum cache in nanoseconds.
 

Detailed Description

Helper class for calculating the frame rate.

Keeps track of the durations of frames over a short measurement window and calculates the average FPS.

Constructor & Destructor Documentation

◆ FrameTimeQueue()

kanzi::FrameTimeQueue::FrameTimeQueue ( )
explicit

Constructor.

Member Function Documentation

◆ update()

void kanzi::FrameTimeQueue::update ( chrono::nanoseconds frameDuration)

Updates the frame time queue with a new frame duration.

Parameters
frameDurationDuration of the new frame in nanoseconds.

◆ getFPS()

KZ_NO_DISCARD float kanzi::FrameTimeQueue::getFPS ( ) const
inline

Returns the current FPS.

Returns
Current frame rate in frames per second.

Member Data Documentation

◆ MeasurementWindowWidth

const chrono::milliseconds kanzi::FrameTimeQueue::MeasurementWindowWidth
static

The maximum duration of the measurement window. Frame duration samples that are older than this are not included in the reported FPS.

◆ MeasurementBufferSize

const size_t kanzi::FrameTimeQueue::MeasurementBufferSize
static

The maximum size of the measurement window. Oldest frame duration samples that don't fit to the buffer are not included in the reported FPS.

◆ m_frames

array<chrono::nanoseconds, MeasurementBufferSize> kanzi::FrameTimeQueue::m_frames
protected

Frame time queue data.

◆ m_firstFrame

size_t kanzi::FrameTimeQueue::m_firstFrame
protected

Frame time queue front index.

◆ m_frameCount

size_t kanzi::FrameTimeQueue::m_frameCount
protected

Frame time queue size.

◆ m_totalTime

chrono::nanoseconds kanzi::FrameTimeQueue::m_totalTime
protected

Frame time queue content sum cache in nanoseconds.

◆ m_fps

float kanzi::FrameTimeQueue::m_fps
protected

Frame rate cache.


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