Add `DiagnosticOverlayStatistic::Max` for displaying long frame time
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
The existing diagnostic overlay system provides no way to display long frame times, i.e. the length of the longest frame in the recorded period. This is vital information for debugging frame hitches. A single frame that takes 100 ms to run, while most frames are running in 10 ms or less, can feel really bad, but when you're only displaying the average frame time it barely shows up, and if you're only displaying the latest frame time it disappears too quickly to read it.
I suspect that displaying the maximum could be useful for other diagnostics as well. Anything where a brief spike in the data might represent a problem which wouldn't be very visible in an average.
## What solution would you like?
It's already possible to iterate the diagnostic data manually, using `Diagnostic::values()`, so you could use that, or add a new `Diagnostic::max()` method, to get the maximum value of a metric. And then add a new value to the `DiagnosticOverlayStatistic` enum for `Max`, to display that max value.
## What alternative(s) have you considered?
You could maybe do a more generalized system, where you can somehow inject some custom code for calculating the metric to display from the raw data. I'm not really sure what this would look like.
Another solution would be to add the ability for the diagnostic overlay to display a running bar graph of the data. Spikes in the data would show up very clearly on a bar graph. This would be a more complicated thing to implement, and definitely slower to render, but could be useful for analyzing a lot of different diagnostics.
Contributor guide
Research direction
Start by locating Diagnostic::values() and the DiagnosticOverlayStatistic enum, then trace how existing overlay statistics are calculated and rendered. Add the maximum statistic so the overlay can display the longest recorded frame or metric value, and verify that the displayed value reflects spikes rather than only averages or the latest sample.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev, performance
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100