Vaelek Posted March 16, 2015 Share Posted March 16, 2015 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. 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.