FPSCounter Class Reference

The FPSCounter class provides methods for calculating the frames per second (FPS) count in periodic tasks. More...

#include <VisionX/tools/FPSCounter.h>

Public Member Functions

void assureFPS (float fFrameRate)
 Synchronize to FPS. More...
 
 FPSCounter (int nDelayFrames=10)
 Constructs a new FPS counter. More...
 
float getFPS ()
 Get frames per second. More...
 
float getMaxCycleTimeMS ()
 Get maximum cycle time since start. More...
 
float getMeanCycleTimeMS ()
 Get mean cycle time over last 10 frames. More...
 
float getMinCycleTimeMS ()
 Get minimum cycle time since start. More...
 
int getUpdates ()
 Get number of updates. More...
 
bool getValid ()
 Get if calculated values are valid. More...
 
void recalculate ()
 recalculates the FPS statistics More...
 
void reset ()
 Resets the FPS counter to its initial state. More...
 
void update ()
 Updates the FPS counter. More...
 

Detailed Description

The FPSCounter class provides methods for calculating the frames per second (FPS) count in periodic tasks.

Further synchronization to a given FPS is supported.

Definition at line 36 of file FPSCounter.h.

Constructor & Destructor Documentation

◆ FPSCounter()

FPSCounter ( int  nDelayFrames = 10)

Constructs a new FPS counter.

Parameters
nDelayFramesnumber of frames to use for FPS calculation. The FPS calculation will be delayed by this amount of frames

Definition at line 38 of file FPSCounter.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ assureFPS()

void assureFPS ( float  fFrameRate)

Synchronize to FPS.

Using this method in a periodic task will synchronize the task to the specified FPS. Update is called internally, so do not call update at a different position.

Parameters
fFrameRateframes per second to use for synchronization

Definition at line 82 of file FPSCounter.cpp.

+ Here is the caller graph for this function:

◆ getFPS()

float getFPS ( )

Get frames per second.

Returns
frames per second measure over the last nDelayTime frames (see constructor)

Definition at line 127 of file FPSCounter.cpp.

+ Here is the caller graph for this function:

◆ getMaxCycleTimeMS()

float getMaxCycleTimeMS ( )

Get maximum cycle time since start.

Returns
maximum cycle time in ms

Definition at line 164 of file FPSCounter.cpp.

+ Here is the caller graph for this function:

◆ getMeanCycleTimeMS()

float getMeanCycleTimeMS ( )

Get mean cycle time over last 10 frames.

Returns
mean cycle time in ms

Definition at line 137 of file FPSCounter.cpp.

+ Here is the caller graph for this function:

◆ getMinCycleTimeMS()

float getMinCycleTimeMS ( )

Get minimum cycle time since start.

Returns
minimum cycle time in ms

Definition at line 154 of file FPSCounter.cpp.

+ Here is the caller graph for this function:

◆ getUpdates()

int getUpdates ( )

Get number of updates.

Returns
number of updates or assureFPS calls performed since start or last reset

Definition at line 122 of file FPSCounter.cpp.

◆ getValid()

bool getValid ( )

Get if calculated values are valid.

Calculated values are valid if the minimum amount of delay frames has passed (m_nDelayFrames, see constructor)

Returns
calculated values valid

Definition at line 117 of file FPSCounter.cpp.

◆ recalculate()

void recalculate ( )

recalculates the FPS statistics

Definition at line 72 of file FPSCounter.cpp.

◆ reset()

void reset ( )

Resets the FPS counter to its initial state.

Definition at line 49 of file FPSCounter.cpp.

+ Here is the caller graph for this function:

◆ update()

void update ( )

Updates the FPS counter.

Using this method in a periodic task will measure the time elapsed from one call to the next. Based on this time, the FPS is calculated.

Definition at line 60 of file FPSCounter.cpp.


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