How do you show fps?


This Is a really noob question but does anyone now how you do this.
I know there is a really simple way but i cant remember this :confused:

There are a variety of ways, and some folks have written classes to display them. The simplest is just"1/DeltaTime"), but that can flicker too fast to see. Slightly better is"math.floor(1/DeltaTime)") which rounds it down to the nearest integer.

What I tend to do is average the frame rate over the last few frames. In setup, I put:

fps = {}
nf = 10
for k=1,nf do

then in draw I have:

afps = 0
for _,v in ipairs(fps) do
    afps = afps + v
afps = math.floor(10/afps)

If using FULLSCREEN (or FULLSCREEN_NO_BUTTONS) then instead of you need to draw the text to the screen.

@Andrew_Stacey Yes but thats not exactly what im looking for :confused:

I’m not sure how Andrew’s response wasn’t what you were after… But you can also check out this tutorial which has FPS as part of it.

@Jessevanderheide Then you need to be a bit more precise about what it is you want.

FPS is frames per second, DeltaTime is the time it took to draw the current frame from the previous frame, this should be 1/60 but if we do 1/DeltaTime it will give you around 57-65 which is a rough estimate of the frame rate or Frames Per Second (FPS)


I remember what i was meaning!
It was almost the same as andrew but a few things were different.
Thanks for the help!