Jump to content

Recommended Posts

Posted

Wanting a better overview of the FPS my map was getting, I came up with the following. Thought I would offer it up in case anyone else may find it useful.

 

In app.lua, at the top add

 

local FPSTable = {}

 

Somewhere add these 2 functions

 

function f(a, b, ...)
 if (B) then return f(a+b, ...) else return a end
end

function Average(n)
 if #FPSTable == 200 then table.remove(FPSTable, 1) end
 FPSTable[#FPSTable + 1] = n
 return f(unpack(FPSTable)) / #FPSTable
end

 

Last, replace the original DrawText line with

 

self.context:DrawText("FPS: "..Math:Round(Average(Time:UPS())),2,2)

 

Instead of showing the FPS as it is calculated at every frame, it will show a rolling average over the last 200 frames. The number of frames to use can be changed in the first line of the Average function.

  • Upvote 3

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...