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

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

Public Member Functions

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

Protected Attributes

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

Detailed Description

Calculate "frame-per-second" of something.

fps.start();
while (true)
{
std::cout << std::round(fps.fps()) << std::endl;
fps.end_frame();
}
float fps()
Retrieve the current FPS value.
Definition: tools.h:106
FramesPerSecond() noexcept
Definition: tools.h:67

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.