-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve fps counter #1886
base: master
Are you sure you want to change the base?
Improve fps counter #1886
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1886 +/- ##
==========================================
- Coverage 95.69% 95.67% -0.03%
==========================================
Files 125 125
Lines 9926 9945 +19
==========================================
+ Hits 9499 9515 +16
- Misses 427 430 +3 ☔ View full report in Codecov by Sentry. |
|
||
if (this->FramesAccumulated == vtkF3DUIActor::FramesToAverage) | ||
{ | ||
this->FpsValue = static_cast<int>(this->AccumulatedFpsValue / this->FramesAccumulated); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it should be a slided average, wdyt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that looks better. I can add that once I'm home from school.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the average must be done in frame time, rather than fps.
So maybe you could pass the elapsed time in this function, average the elapsed time, and only inverse it at the end to convert to fps.
If you don't do that, the average will be biased with highest fps values.
Also, I don't like the idea of the fps value at 0 for the first 5 frames.
About the slided average, I'm afraid it will still produce large variation of fps and will still make the fps value unreadable. But maybe if we increase the window size to something larger than 5, this effect could be mitigated.
Here's a suggestion:
- Add the elapsed time in a container (
std::queue
but maybe another container is more adapted) - Remove the oldest value if the number of elements is above the window size
- Average all the elements
- Inverse the value to get the fps value
Let's see if the value can be read and if changing the window size have an effect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good will try to implement this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove the oldest value if the number of elements is above the window size
How can the renderer get the window size (in it's information maybe?). And why should that affect the fps average?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, wdyt @Meakk ?
…liding average of time between frames
I don't think the last commit works but I don't know why? |
SetFpsValue()
toUpdateFpsValue()
which will automatically accumulate fps values before setting the display value to the average. The number of frames it waits to average is decided by the static member variablevtkF3DUIActor::FramesToAverage
vtkF3DRenderer::Render()
function I updated it to check if its information hasvtkF3DRenderPass::RENDER_UI_ONLY()
set to 1 If it does it calculates the fps value and calls the UI Actor'sUpdateFpsValue()
Let me know what you think the number of frames to average should be (currently set to 5).
From building it and using some of the example models it seems that the render UI only is working however I may be wrong.
Seeing this is my first time contributing I'm starting a pull request to get some advice.