GUI: add timing debug info

This commit is contained in:
tildearrow 2022-05-27 00:19:10 -05:00
parent 061b312943
commit 5d1785fb38
3 changed files with 35 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "gui.h" #include "gui.h"
#include "debug.h" #include "debug.h"
#include "IconsFontAwesome4.h" #include "IconsFontAwesome4.h"
#include <SDL_timer.h>
#include <fmt/printf.h> #include <fmt/printf.h>
#include <imgui.h> #include <imgui.h>
@ -370,6 +371,13 @@ void FurnaceGUI::drawDebug() {
} }
ImGui::TreePop(); ImGui::TreePop();
} }
if (ImGui::TreeNode("Performance")) {
double perfFreq=SDL_GetPerformanceFrequency()/1000000.0;
ImGui::Text("render: %.0fµs",(double)renderTimeDelta/perfFreq);
ImGui::Text("layout: %.0fµs",(double)layoutTimeDelta/perfFreq);
ImGui::Text("event: %.0fµs",(double)eventTimeDelta/perfFreq);
ImGui::TreePop();
}
if (ImGui::TreeNode("Settings")) { if (ImGui::TreeNode("Settings")) {
if (ImGui::Button("Sync")) syncSettings(); if (ImGui::Button("Sync")) syncSettings();
ImGui::SameLine(); ImGui::SameLine();

View File

@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include <SDL_timer.h>
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include "gui.h" #include "gui.h"
#include "util.h" #include "util.h"
@ -2411,6 +2412,7 @@ bool FurnaceGUI::loop() {
drawHalt=0; drawHalt=0;
if (settings.powerSave) SDL_WaitEventTimeout(NULL,500); if (settings.powerSave) SDL_WaitEventTimeout(NULL,500);
} }
eventTimeBegin=SDL_GetPerformanceCounter();
while (SDL_PollEvent(&ev)) { while (SDL_PollEvent(&ev)) {
WAKE_UP; WAKE_UP;
ImGui_ImplSDL2_ProcessEvent(&ev); ImGui_ImplSDL2_ProcessEvent(&ev);
@ -2720,6 +2722,10 @@ bool FurnaceGUI::loop() {
midiQueue.pop(); midiQueue.pop();
midiLock.unlock(); midiLock.unlock();
} }
eventTimeEnd=SDL_GetPerformanceCounter();
layoutTimeBegin=SDL_GetPerformanceCounter();
ImGui_ImplSDLRenderer_NewFrame(); ImGui_ImplSDLRenderer_NewFrame();
ImGui_ImplSDL2_NewFrame(sdlWin); ImGui_ImplSDL2_NewFrame(sdlWin);
@ -3740,6 +3746,8 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup(); ImGui::EndPopup();
} }
layoutTimeEnd=SDL_GetPerformanceCounter();
// backup trigger // backup trigger
if (modified) { if (modified) {
if (backupTimer>0) { if (backupTimer>0) {
@ -3778,10 +3786,16 @@ bool FurnaceGUI::loop() {
uiColors[GUI_COLOR_BACKGROUND].z*255, uiColors[GUI_COLOR_BACKGROUND].z*255,
uiColors[GUI_COLOR_BACKGROUND].w*255); uiColors[GUI_COLOR_BACKGROUND].w*255);
SDL_RenderClear(sdlRend); SDL_RenderClear(sdlRend);
renderTimeBegin=SDL_GetPerformanceCounter();
ImGui::Render(); ImGui::Render();
renderTimeEnd=SDL_GetPerformanceCounter();
ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData());
SDL_RenderPresent(sdlRend); SDL_RenderPresent(sdlRend);
layoutTimeDelta=layoutTimeEnd-layoutTimeBegin;
renderTimeDelta=renderTimeEnd-renderTimeBegin;
eventTimeDelta=eventTimeEnd-eventTimeBegin;
if (--soloTimeout<0) soloTimeout=0; if (--soloTimeout<0) soloTimeout=0;
wheelX=0; wheelX=0;
@ -4283,6 +4297,15 @@ FurnaceGUI::FurnaceGUI():
bindSetPending(false), bindSetPending(false),
nextScroll(-1.0f), nextScroll(-1.0f),
nextAddScroll(0.0f), nextAddScroll(0.0f),
layoutTimeBegin(0),
layoutTimeEnd(0),
layoutTimeDelta(0),
renderTimeBegin(0),
renderTimeEnd(0),
renderTimeDelta(0),
eventTimeBegin(0),
eventTimeEnd(0),
eventTimeDelta(0),
transposeAmount(0), transposeAmount(0),
randomizeMin(0), randomizeMin(0),
randomizeMax(255), randomizeMax(255),

View File

@ -1189,6 +1189,10 @@ class FurnaceGUI {
float nextScroll, nextAddScroll; float nextScroll, nextAddScroll;
int layoutTimeBegin, layoutTimeEnd, layoutTimeDelta;
int renderTimeBegin, renderTimeEnd, renderTimeDelta;
int eventTimeBegin, eventTimeEnd, eventTimeDelta;
ImVec2 patWindowPos, patWindowSize; ImVec2 patWindowPos, patWindowSize;
// pattern view specific // pattern view specific