Finding EXACT FPS through script

How do you find the exact FPS of your game through script? I tried Time.deltaTime and some of its relatives in the Time class, but alas, none of them synchronized with the frame rate in Game / Stats. Anybody know how to fix this? Any help would be greatly appreciated!

Instantaneous framerate is going to be 1.0f / Time.deltaTime.

No idea what is in Game/Stats. Does that matter?

The tab that says “Stats” in the top right when you start up the game in the editor. It usually says 80-90 FPS there, but my in-game counter always is 59-60. Any ideas?

That number is an estimate by the editor and not accurate since it is slowed down by the editor itself. Build speeds are the only numbers you should be looking at.

It’s probably faster because the view window is smaller and you play the build at fullscreen so there’s a big difference in how much rendering is necessary.

1 Like

Bolded what I would guess is causing the discrepancy.

The stats in the editor do not represent the actual FPS, because it is not including any editor only processing. They are basically an estimate of what a build would be running at with the same resolution as the game view window, but even that is not very accurate. A release build version would remove a lot of the debugging support and include a lot of code optimizations that are not done for the editor version.

So really, the stats window FPS is just usable as a rough guess, or to compare before and after numbers when you make a significant change. The real FPS numbers you should always get from a release build.

2 Likes