Calculating frames per second in a game

What's a good algorithm for calculating frames per second in a Gta v game? I want to show it as a number in the corner of the screen. If I just look at how long it took to render the last frame the number changes too fast.

Bonus points if your answer updates each frame and doesn't converge differently when the frame rate is increasing vs decreasing.

Python 31-12-22, 12:36 p.m. isaniawert

Log-in to answer to this question.