Module src.streaming.framerate_calculator

Module for calculating framerate

Classes

class FramerateCalculator (length: int)

Keeps track of timestamps, and uses these to calculate average and live framerate

Args

length
The size of the backlog of times, the number of frames to average over.

Methods

def timestamp(self, time: float) ‑> NoneType

Timestamps current time

Calculates framerate based on the difference in time from this and the previous call to this method. It then adds that to the backlog.

This method can then be run once per frame, and should yield an accurate framerate.

Args

time
Current time.
def get_fps(self) ‑> int

Gets current framerate from last item in backlog

def get_average_fps(self) ‑> int

Calculates average over all framerates in backlog