Scripting | FPS Log

Hello!

How might I log a player’s FPS?
Like it would set a variable to the current FPS and a variable to the previous FPS, and it would go in a loop.

Thanks!

4 Likes

Do you mean something like this?

local fpsCurr = 0
local fpsLast = 0

game:service("RunService").RenderStepped:Connect(function()
    fpsCurr = fpsCurr + 1
end)

while true do
    wait(1)
    print(fpsCurr)
    print(fpsLast)
    fpsLast = fpsCurr
    fpsCurr = 0
end

There is a lot of posts about your topic. Using this Post about FPS, It appears that there there is 3 ways to do this:

You could get the PhysicsFPS:

workspace:GetRealPhysicsFPS()

That this is probably not what your looking for, but someone else linked a script to get the Clients FPS:

local RunService = game:GetService("RunService")
local FpsLabel = script.Parent

local TimeFunction = RunService:IsRunning() and time or os.clock

local LastIteration, Start
local FrameUpdateTable = {}

local function HeartbeatUpdate()
	LastIteration = TimeFunction()
	for Index = #FrameUpdateTable, 1, -1 do
		FrameUpdateTable[Index + 1] = FrameUpdateTable[Index] >= LastIteration - 1 and FrameUpdateTable[Index] or nil
	end

	FrameUpdateTable[1] = LastIteration
	FpsLabel.Text = tostring(math.floor(TimeFunction() - Start >= 1 and #FrameUpdateTable or #FrameUpdateTable / (TimeFunction() - Start))) .. " FPS"
end

Start = TimeFunction()
RunService.Heartbeat:Connect(HeartbeatUpdate)

or

function getFps()

return (1/game:GetService("RunService").RenderStepped:Wait())

end
local FPS = getFps()

@OfficialPogCat @TheeDeathCaster

Thank you for both of your responses.

However, I am not sure either of your solutions worked.
Basically, I am trying to set the last 3 instances of the player’s FPS. Ex:

CurrentFPS: –
LastFPS: –
LastLastFPS: –

Let me know if this helps.
Thanks!

-- written in the textbox, might be trash and no idea if it works!

local CurrentFps = 0
local LastFps = 0
local LastLastFps = 0

game:FindFirstChildOfClass("RunService").PreRender:Connect(function(DeltaTime)
LastLastFps = LastFps
LastFps = CurrentFps
CurrentFps = 1 / DeltaTime

print(CurrentFps, LastFps, LastLastFps)
end)

It doesn’t seem to be working…

77.48634364507917 39.44524099232822 94.75708678094378  -  Client

I’m not sure why it acts like that, but I think it does work, or at least it did what you asked for.
Unless there’s a big lag spike it won’t be so noticeable, after all it’s only 3 frames.

Yeah, let me rephrase.

So basically, this code will get 3 variables, FirstFPS, SecondFPS, and ThirdFPS, it will print this every 3 seconds, bc FPS = frames per second.

It is kinda hard to explain, but if you have any more questions feel free to let me know.

no. it will print the current value of those 3 variables every time ur screen is rendered.

But is there a way to do that?

local CurrentFps, PastFps, PastPastFps 
function getFps()

return (1/game:GetService("RunService").RenderStepped:Wait())

end

repeat
PastPastFps = PastFps
PastFps = CurrentFps
CurrentFps = getFps()
task.wait(0.1)
if PastPastFps ~= nil then
print("Current: "..CurrentFps.." Past: "..PastFps.." PastPast: "..PastPastFps)
end
until false
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.