1.10
Public Member Functions | Protected Attributes | List of all members
FramesPerSecond Class Reference

Calculate "frame-per-second" of something. More...

#include <tools.h>

Public Member Functions

 FramesPerSecond () noexcept
 
void end_frame ()
 Call at the end of every frame.
 
float fps ()
 Retrieve the current FPS value.
 
EGT_NODISCARD bool ready () const
 Is any calculation ready?
 
void start ()
 Start/reset the counter.
 

Protected Attributes

float m_fps {0.}
 Calculated FPS.
 
uint64_t m_frames {0}
 Number of frames recorded since start time.
 
bool m_ready {false}
 Is m_fps valid and ready?
 
std::chrono::time_point< std::chrono::steady_clock > m_start {}
 Start time.
 

Detailed Description

Calculate "frame-per-second" of something.

while (true)
{
std::cout << std::round(fps.fps()) << std::endl;
fps.end_frame();
}
Calculate "frame-per-second" of something.
Definition tools.h:64
void start()
Start/reset the counter.
Definition tools.h:75
float fps()
Retrieve the current FPS value.
Definition tools.h:106

Constructor & Destructor Documentation

◆ FramesPerSecond()

FramesPerSecond ( )
inlinenoexcept

Member Function Documentation

◆ end_frame()

void end_frame ( )
inline

Call at the end of every frame.

◆ fps()

float fps ( )
inline

Retrieve the current FPS value.

◆ ready()

EGT_NODISCARD bool ready ( ) const
inline

Is any calculation ready?

◆ start()

void start ( )
inline

Start/reset the counter.

Member Data Documentation

◆ m_fps

float m_fps {0.}
protected

Calculated FPS.

◆ m_frames

uint64_t m_frames {0}
protected

Number of frames recorded since start time.

◆ m_ready

bool m_ready {false}
protected

Is m_fps valid and ready?

◆ m_start

std::chrono::time_point<std::chrono::steady_clock> m_start {}
protected

Start time.