diff --git a/src/gui/debugWindow.cpp b/src/gui/debugWindow.cpp index 41f11271..7d6d057f 100644 --- a/src/gui/debugWindow.cpp +++ b/src/gui/debugWindow.cpp @@ -20,6 +20,7 @@ #include "gui.h" #include "debug.h" #include "IconsFontAwesome4.h" +#include #include #include @@ -370,6 +371,13 @@ void FurnaceGUI::drawDebug() { } 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::Button("Sync")) syncSettings(); ImGui::SameLine(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 2aaee330..11383b9b 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include #define _USE_MATH_DEFINES #include "gui.h" #include "util.h" @@ -2411,6 +2412,7 @@ bool FurnaceGUI::loop() { drawHalt=0; if (settings.powerSave) SDL_WaitEventTimeout(NULL,500); } + eventTimeBegin=SDL_GetPerformanceCounter(); while (SDL_PollEvent(&ev)) { WAKE_UP; ImGui_ImplSDL2_ProcessEvent(&ev); @@ -2720,6 +2722,10 @@ bool FurnaceGUI::loop() { midiQueue.pop(); midiLock.unlock(); } + + eventTimeEnd=SDL_GetPerformanceCounter(); + + layoutTimeBegin=SDL_GetPerformanceCounter(); ImGui_ImplSDLRenderer_NewFrame(); ImGui_ImplSDL2_NewFrame(sdlWin); @@ -3740,6 +3746,8 @@ bool FurnaceGUI::loop() { ImGui::EndPopup(); } + layoutTimeEnd=SDL_GetPerformanceCounter(); + // backup trigger if (modified) { if (backupTimer>0) { @@ -3778,10 +3786,16 @@ bool FurnaceGUI::loop() { uiColors[GUI_COLOR_BACKGROUND].z*255, uiColors[GUI_COLOR_BACKGROUND].w*255); SDL_RenderClear(sdlRend); + renderTimeBegin=SDL_GetPerformanceCounter(); ImGui::Render(); + renderTimeEnd=SDL_GetPerformanceCounter(); ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData()); SDL_RenderPresent(sdlRend); + layoutTimeDelta=layoutTimeEnd-layoutTimeBegin; + renderTimeDelta=renderTimeEnd-renderTimeBegin; + eventTimeDelta=eventTimeEnd-eventTimeBegin; + if (--soloTimeout<0) soloTimeout=0; wheelX=0; @@ -4283,6 +4297,15 @@ FurnaceGUI::FurnaceGUI(): bindSetPending(false), nextScroll(-1.0f), nextAddScroll(0.0f), + layoutTimeBegin(0), + layoutTimeEnd(0), + layoutTimeDelta(0), + renderTimeBegin(0), + renderTimeEnd(0), + renderTimeDelta(0), + eventTimeBegin(0), + eventTimeEnd(0), + eventTimeDelta(0), transposeAmount(0), randomizeMin(0), randomizeMax(255), diff --git a/src/gui/gui.h b/src/gui/gui.h index 7d5e62a7..90b4e283 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1189,6 +1189,10 @@ class FurnaceGUI { float nextScroll, nextAddScroll; + int layoutTimeBegin, layoutTimeEnd, layoutTimeDelta; + int renderTimeBegin, renderTimeEnd, renderTimeDelta; + int eventTimeBegin, eventTimeEnd, eventTimeDelta; + ImVec2 patWindowPos, patWindowSize; // pattern view specific