x


profiler fps vs. stats fps vs. Time.deltaTime

I tried to profile my game and at the moment Im a bit confused about whick values to trust.

The stats window in my game view reports 140fps. Time.deltaTime is somewhere around 0.02 on average, which would mean 50fps. The profiler reports a few spikes (GC etc.), but on average the frame rate reported by the profiler should be around 1000fps.

So which one should I trust, and why do I get all those different reports?

more ▼

asked Nov 09, 2010 at 05:16 PM

StephanK gravatar image

StephanK
6.5k 116 106 158

Good question. I've noticed times when the Stats window claims fps of 50+ but I could watch the screen and count the frames as they go by. The Stats window tries to factor out the overhead of the editor running and so forth, but it often seems over-optimistic about how fast my game is running.

Dec 14, 2010 at 07:47 PM yoyo
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

This is an interesting question and I wish I had the definitive answer as to which to trust, but the truth is that none of them is 100% correct.

The stats window is likely closest for something like fps, but it's quite hard to say. Time.deltaTime should be the most accurate, but the overhead of writing out the values changes the results. The profiler's estimate for fps is too generous.

One of the reasons that you get three different values has to do with where the values are coming from, especially if all three are happening simultaneously. Bear in mind that all of these stats are running in the editor which also incurs some overhead that the stats window and profiler will try to accomodate for.

The stats window is a rough approximation of what's really happening in the game view to try and give you an idea of what the run-time performance of the scene is going to be at, but you shouldn't trust it as definitive because it is often wrong (try working out the draw calls for example).

Time.deltaTime is giving you representative values of what is actually happening. This is accurate, but since you are running in the editor, this value is likely less than Unity predicts your run-time to be. Moreover, if you only write to the log for this test case as opposed to writing it for all three, it would even further offset the values as writing to the log is apparently not cheap (I've actually been able to pretty much freeze Unity with some for loops that just write to the log).

The profiler is going to try and guesstimate what it thinks your final run-time fps will be at. This is very off because simply running the profiler eats a lot of memory in and of itself, affecting the results so it must predict to a fair degree. For things other than fps, the profiler should be fairly accurate.

more ▼

answered Nov 09, 2010 at 07:44 PM

skovacs1 gravatar image

skovacs1
11.2k 17 39 110

(comments are locked)
10|3000 characters needed characters left

The stats window tells you how long it takes to draw the graphics. This is only sort of related to how fast your game actually runs in terms of frames per second, because it's totally ignoring everything else. It's not a matter of "which is more accurate" than the profiler, since it's two quite different pieces of information altogether.

In any case, the editor has a lot of overhead that's not present when running a build on its own, so for truly accurate fps info, you should use this script in an actual build.

more ▼

answered Nov 09, 2010 at 08:14 PM

Eric5h5 gravatar image

Eric5h5
111k 55 189 675

Maybe I don't get it, but after a small test I'm pretty sure that the stats window definetly takes into account more than just the draw time for graphics. If you insert some stupid but lengthy loop into your update you can see the fps in the stats window drop. Also I know that I have a lot of overhead using the editor and profiler (let alone deep profiling), but I am confused why the profiler reports a much HIGHER fps. Does it try to predict the times and frame rate that I could expect in a build version?

Nov 10, 2010 at 08:03 AM StephanK
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1121
x270

asked: Nov 09, 2010 at 05:16 PM

Seen: 4116 times

Last Updated: Nov 09, 2010 at 05:16 PM