PresentMon icon indicating copy to clipboard operation
PresentMon copied to clipboard

how does presentmon calculate the fps?

Open hedihadi opened this issue 1 year ago • 1 comments

hello, i'm trying to use presentmon in my application. the way i show "current fps" is by getting the last 10 (1000/msBetweenPresents) records and get the average number, but obviously this is not accurate at all.

how does presentmon calculates this value (38.2 value in the screenshot below)? image thank you in advance!

EDIT/ i know i'm supposed to look at the source code, but i have a really hard time navigating around the c++ code. sorry about that!

hedihadi avatar Feb 24 '24 10:02 hedihadi

No problem about reading the code, these sorts of questions are totally fine for the github issues.

You should either use harmonic_mean(1000/msBetweenPresents) or 1000/mean(msBetweenPresents).

The console application uses the latter along with the optimization: mean(msBetweenPresents) = (last_present_time - first_present_time) / (num_presents - 1). And it computes the average over the last 120 frames, or the last 2 seconds worth of frames, which ever is less.

Code is here: https://github.com/GameTechDev/PresentMon/blob/main/PresentMon/Console.cpp#L267

HTH