Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#1016 closed defect (fixed)

[PATCH] Fix frame rate counter

Reported by: historic_bruno Owned by: ben
Priority: Nice to Have Milestone: Alpha 13
Component: Core engine Keywords: patch
Cc: Patch:

Description

The frame rate counter (Shift+F) jumps around too much, the implementation should be filtering the time between frames to produce a smooth average, but it's obviously not working as intended.

Attachments (2)

0002-Implement-an-averaged-frequency-counter-to-get-a-mor.patch (2.3 KB ) - added by sbte 11 years ago.
100 frames average FPS patch
0002-Implement-an-averaged-frequency-counter-to-get-a-mor.2.patch (2.7 KB ) - added by sbte 11 years ago.
Patch to take an average over the last 2 seconds

Download all attachments as: .zip

Change History (9)

by sbte, 11 years ago

100 frames average FPS patch

comment:1 by sbte, 11 years ago

I added a patch that keeps an average over 100 frames and shows that as the FPS. This is certainly a lot smoother. It also checks for huge spikes, to compensate for instance for going from the loading screen to the game.

What the previous method did was only changing the FPS if there was a spike over an average of 3 frames. This is why you experienced it as jumping around a lot.

I hope you like the patch.

comment:2 by leper, 11 years ago

Keywords: patch review added
Milestone: BacklogAlpha 13
Summary: Fix frame rate counter[PATCH] Fix frame rate counter

comment:3 by historic_bruno, 11 years ago

Thanks for the patch. I've tested and it's somewhat of an improvement. If I understand the code, it's taking the "smoothed" frequency from an IIR filter and doing a moving average over 100 frames. This average/stable frequency is only used for FPS display.

The only problem I see is that 100 frames doesn't always seem to be appropriate. For example, on the main menu, I'm getting over 800 fps right now, so 100 frames is only 1/8 of a second, which causes lots of fluctuation. Using a larger number of samples seems to work well, like 500-100 frames. It will respond more slowly to relatively small changes in frequency, but I don't think that is necessarily undesirable for a fps counter. If someone wants more accurate performance info they should use the profiler or some other tool anyway. Or maybe there's a way to adjust the sample size on the fly?

Any thoughts?

comment:4 by fabio, 11 years ago

What about updateing the display every second, counting the frames in it?

by sbte, 11 years ago

Patch to take an average over the last 2 seconds

comment:5 by sbte, 11 years ago

You indeed understood my patch correctly. I now modified the patch to take an average over the last two seconds instead of the last 100 frames. Is that better?

I don't think we can ever get a stable amount of FPS in the menu, unless we only change the FPS that are displayed at a certain interval (say one second). But I don't think that's needed either. For me at least, the stability of the FPS in the game seems quite reasonable.

comment:6 by ben, 11 years ago

Owner: set to ben
Resolution: fixed
Status: newclosed

In 13204:

Improves frame rate counter to give smoother results, patch by sbte. Fixes #1016

comment:7 by historic_bruno, 11 years ago

Keywords: review removed

Looks good to me, thanks!

Note: See TracTickets for help on using tickets.