[effects/showfps] Calculate "correct" FPS
ClosedPublic

Authored by zzag on Apr 28 2020, 7:44 AM.

Details

Summary

cca0e15b455ba6 broke code that calculates the value of the fps counter.

The frames field stores timestamps of previous frames, not time between
each two consecutive frames.

This change doesn't attempt to make the show fps compute more accurate
performance metrics, e.g. how much times it takes to execute rendering
commands on the GPU, etc.

Test Plan

The Show FPS effect displays more sensible values.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
zzag created this revision.Apr 28 2020, 7:44 AM
Restricted Application added a project: KWin. · View Herald TranscriptApr 28 2020, 7:44 AM
Restricted Application added a subscriber: kwin. · View Herald Transcript
zzag requested review of this revision.Apr 28 2020, 7:44 AM
broulik added inline comments.
effects/showfps/showfps.cpp
126 ↗(On Diff #81414)

Can you not store the current time of the timer rather than going through QDateTime?

zzag added inline comments.Apr 28 2020, 9:44 AM
effects/showfps/showfps.cpp
126 ↗(On Diff #81414)

Uh, do you suggest to use an alternative approach for counting fps?

zzag added a comment.EditedMay 6 2020, 8:10 AM

Just to be clear... The Show FPS effect assigns a timestamp to every frame and then counts how many frames were painted within the last second. This patch only intends to fix a regression and not change the frame counting algorithm. Let's discuss whether the frame counting algorithm is good somewhere else, e.g. a Phabricator task or kwin mailing list.

davidedmundson accepted this revision.May 6 2020, 2:29 PM
davidedmundson added a subscriber: davidedmundson.

It certainly is weird to use a combo of QElapsedTimer and timestamps, but sure, lets discuss that another day

This revision is now accepted and ready to land.May 6 2020, 2:29 PM
This revision was automatically updated to reflect the committed changes.