# How long is your average frame?

This topic is 2158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

I've been profiling my DIY 3d engine after doing some major improvements on my renderqueue. With this I'm using pix.

The results per frame are somewhere between:

100.000.000 and 200.000.000 duration (FPS 5.1?)

I'm assuming that these are nano seconds, coming down to 0.1 to 0.2 seconds per frame.

With 60 fps I'd assume without skipping frames, a frame should take 1 / 60 = 0.016 second.

A few questions:

- are these assumptions correct?

- if so, why does it seem to run so 'flawless' with somewhere to 6 FPS?

- how can I see in PIX if I might be CPU versus GPU bound?

- how lang are your average frames taking, with similar measurements?

Ps.; I'm not aiming to start off and go optimizing, because I don't have performance issues with the current scenes and things I'm doing. Just curious and wanting to understand the measurements. Here's a screenshot of a captured frame in PIX.

##### Share on other sites

There are 1,000,000,000 nanoseconds in a single second so a frame time between 100 and 200 nanoseconds would corresponding to an fps between 10,000,000 and 5,000,000.  This is highly unlikely.  I believe PIX can be configured to display times in cycles, milliseconds, microseconds and possibly other units.  I'm only familiar with PIX for the 360 which I routinely switch between displaying cycle counts and milliseconds elapsed.  Poke around the GUI to figure out how to do this or search the documentation.

It's possible your measured frame time of 100 and 200 is actually in microseconds corresponding to a frame rate of 10,000 to 5,000 fps.  This is still extremely high and therefore suspicious.

An average frame rate is somewhere between 16 and 33 milliseconds roughly corresponding to 60 to 30 fps.

Edited by nonoptimalrobot

##### Share on other sites
Thanks. If somewhere between 16 and 33ms roughly corresponds to 30 up to 60fps, then my 100 to 200ms for a frame would be 'bad'/ quite slow?
(when I reach almost 200, in the screenshot above, the FPS column says 5.1 fps)

Not sure if I understand correct, but this tells then that having between 16.000.000 and 32.000.000 measured time for a frame would be between 30 and 60fps. Have to fid out what's going wrong then, the number of state changes, shader constant sets and drawcalls is not that high (even quite low then I reach 100ms, with 6 esh instances, 3 different materials and one shader/ effect, single pass).

##### Share on other sites

Thanks. If somewhere between 16 and 33ms roughly corresponds to 30 up to 60fps, then my 100 to 200ms for a frame would be 'bad'/ quite slow?
(when I reach almost 200, in the screenshot above, the FPS column says 5.1 fps)

Not sure if I understand correct, but this tells then that having between 16.000.000 and 32.000.000 measured time for a frame would be between 30 and 60fps. Have to fid out what's going wrong then, the number of state changes, shader constant sets and drawcalls is not that high (even quite low then I reach 100ms, with 6 esh instances, 3 different materials and one shader/ effect, single pass).

Yeah, somewhere things are going wrong.  I can't deduce much from your PIX screen grab but you appear to be creating a 1920x1080 surface every frame?  That's probably not necessary and would definitely slow things down.  There is also some locking and unlocking of a surface, maybe the same surface?

##### Share on other sites

Thanks, I've been playing around with PIX and found the following things:

- the screenshot above was where I captured one single frame (with F12)

- when I do a 'run' (record it), and look at individual frames during the run, they all appear around 16 milliseconds

(a few examples: 16.671.232, 16.522.240)

- I found out about the creation of the surface... too stupid, F12 in my engine creates a screenshot ...., changed that now

I see now that a single frame goes down from about 15ms up to 90ms (90ms for a more 'complex' scene).

I have a FPS timer updating each frame, giving a certain speedfactor, this factor is multiplied by the amounts of movement, freelook etc. The requested 'speed' I set here is 50fps. But this shouldn't affect the framerate in rendering I'd think.

Although it seems to 'strange' that almost all frames hit around 16ms, when I record a run.

Edited by cozzie

##### Share on other sites

Although it seems to 'strange' that almost all frames hit around 16ms, when I record a run.

sound like wait for vsync is turned on. at 60Hz refresh rate, your monitor runs at 60 fps = 16.666 ms per frame. with wait for vsync turned on, the monitor's refresh rate acts as a frame rate limiter. this keeps the game from running faster on faster pc's.   since the monitor only copies the vidram to the screen at 60 fps, there's no reason to draw faster. so you get 180 fps? who cares! all that means is you write to vidram 3 times and then the monitor copies to the screen once. the other two writes are lost (overwritten before they can be displayed).

anything longer than 66ms per frame (15 fps) will be unplayable. your 200ms scenes will need work (scene simplification and / or code optimization).

if you're not rock steady at 16ms all the time for all scenes (or 33ms or whatever you choose), a variable time step may cause problems as well.  variable time steps do not degrade gracefully under heavy load.

note that the traditional targets speeds of 30 and 60 fps were originally based on light weight shooters with an emphasis on animation smoothness over scene complexity and simulation depth.  games can actually run as slow as 15 fps and be sufficiently responsive to not inhibit game play.

i actually target 15 fps, which gives me 66ms to put some serious game behind those frames i'm drawing - or the time to draw complex scenes (like 100 animated characters onscreen at once).

Edited by Norman Barrows

##### Share on other sites

Thanks for clearing up, sounds clear. I'll turn V-sync off just to see the difference and as practice (and then back on).

The strange thing is that I only get higher frame times when I capture a single frame with PIX (somewhere from 16ms up to 90ms).

But when I record a certain amount of time, I actually can only find frames with about 16ms (or 1 or 2 ms lower).

Not sure of PIX does something different when I capture just one frame. Doing this is definately usefull to profile settings shader constants, states etc.

By using PIX I actually found quite some 'stupid' things I was doing, setting materials that don't have any meshes (instances) visable. Selecting meshes (indices/ streamsource), for meshes that have no visible instances at al. and more and more :)

One thing I don't understand yet using PIX, is how 'to read' the bar on top, showing you the load on CPU and GPU. To figure out if the CPU is 'frames' ahead or of the GPU is idling. Telling me I could do less on the CPU side, and more to the GPU etc.

If anyone knows how 'to read' this....

Here's an example of my 'run':

##### Share on other sites
Update; I've tried it without v-sync, then my framerate goes from 60 up to around 600fps, but offcourse my time delta is messed up :) turned it back off and did no further profiling.

I'll just do a check once in a while if I keep hitting up to around 16ms per fame.

Any advice on understanding the gpu/cpu load in PIX is still appreciated

##### Share on other sites

Found it, I didn't enable 'Statistics for each frame, using counter set'.

My conclusions:

- in about 95% of all frames, it looks fine, GPU is just a bit later than the CPU (blue means 'rendering a packet of work sent by the CPU').

The difference in the timeline looks fine to me

- in some exceptions there's some red (GPU blocked, waiting for a resource) or grey (GPU is idle)

If I'm interpreting wrong, please let me know.

For now I'm happy with the results and going back to introducing nice and fun new stuff :)

• 18
• 18
• 11
• 21
• 16