main/debug: Make the frame timing graph a sliding window
Use memmove to shift the whole array by one measure to the left, dropping the oldest one and adding a new one at the head. This creates a better visual effect of a graph being produced on the right and scrolling to the left, rather than a looping writing head that overwrites previous data.
This commit is contained in:
parent
41437cd259
commit
940c1d706b
1 changed files with 6 additions and 1 deletions
7
main.cpp
7
main.cpp
|
@ -115,7 +115,12 @@ int main()
|
||||||
ImGui::SetNextWindowBgAlpha(0.2f);
|
ImGui::SetNextWindowBgAlpha(0.2f);
|
||||||
ImGui::Begin("FPS", nullptr ,window_flags);
|
ImGui::Begin("FPS", nullptr ,window_flags);
|
||||||
if (fpsDataClock.getElapsedTime().asMilliseconds() > 20) {
|
if (fpsDataClock.getElapsedTime().asMilliseconds() > 20) {
|
||||||
frameTimings[frameCount%100] = static_cast<float>(deltaT.asMicroseconds());
|
if (frameCount >= 100) {
|
||||||
|
memmove(frameTimings, frameTimings + 1, 99 * sizeof(float));
|
||||||
|
frameTimings[99] = static_cast<float>(deltaT.asMicroseconds());
|
||||||
|
} else [[unlikely]] {
|
||||||
|
frameTimings[frameCount] = static_cast<float>(deltaT.asMicroseconds());
|
||||||
|
}
|
||||||
frameCount++;
|
frameCount++;
|
||||||
fpsDataClock.restart();
|
fpsDataClock.restart();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue