Basic CPU graphs using ImPlot (#838)
This commit is contained in:
parent
62085539a7
commit
4b53edb3bd
|
@ -651,7 +651,19 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE _7ZIP_ST)
|
|||
target_sources(${PROJECT_NAME} PRIVATE core/deps/lzma/7zArcIn.c core/deps/lzma/7zBuf.c core/deps/lzma/7zCrc.c core/deps/lzma/7zCrcOpt.c core/deps/lzma/7zDec.c core/deps/lzma/7zFile.c core/deps/lzma/7zStream.c core/deps/lzma/Alloc.c core/deps/lzma/Bcj2.c core/deps/lzma/Bra86.c core/deps/lzma/Bra.c core/deps/lzma/BraIA64.c core/deps/lzma/CpuArch.c core/deps/lzma/Delta.c core/deps/lzma/LzFind.c core/deps/lzma/Lzma2Dec.c core/deps/lzma/Lzma86Dec.c core/deps/lzma/Lzma86Enc.c core/deps/lzma/LzmaDec.c core/deps/lzma/LzmaEnc.c core/deps/lzma/LzmaLib.c core/deps/lzma/Sort.c)
|
||||
target_sources(${PROJECT_NAME} PRIVATE core/deps/libelf/elf32.cpp core/deps/libelf/elf64.cpp core/deps/libelf/elf.cpp)
|
||||
if(NOT LIBRETRO)
|
||||
target_sources(${PROJECT_NAME} PRIVATE core/deps/imgui/imgui.cpp core/deps/imgui/imgui_demo.cpp core/deps/imgui/imgui_draw.cpp core/deps/imgui/imgui_widgets.cpp)
|
||||
target_sources(${PROJECT_NAME} PRIVATE
|
||||
core/deps/imgui/imgui.cpp
|
||||
core/deps/imgui/imgui_demo.cpp
|
||||
core/deps/imgui/imgui_draw.cpp
|
||||
core/deps/imgui/imgui_widgets.cpp)
|
||||
|
||||
if(ENABLE_FC_PROFILER)
|
||||
target_sources(${PROJECT_NAME} PRIVATE
|
||||
core/deps/implot/implot.h
|
||||
core/deps/implot/implot.cpp
|
||||
core/deps/implot/implot_internal.h
|
||||
core/deps/implot/implot_items.cpp)
|
||||
endif()
|
||||
endif()
|
||||
target_sources(${PROJECT_NAME} PRIVATE core/deps/xbrz/xbrz.cpp)
|
||||
target_sources(${PROJECT_NAME} PRIVATE core/deps/md5/md5.cpp)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Evan Pezent
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -2,6 +2,7 @@
|
|||
#include "log/LogManager.h"
|
||||
#include "cfg/option.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "implot/implot.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace fc_profiler
|
||||
|
@ -131,4 +132,28 @@ namespace fc_profiler
|
|||
outputTTY(node.children);
|
||||
}
|
||||
}
|
||||
|
||||
void drawGraph(const ProfileThread& profileThread)
|
||||
{
|
||||
char threadName[256];
|
||||
std::snprintf(threadName, 256, "Thread %s", profileThread.threadName.c_str());
|
||||
|
||||
if (ImPlot::BeginPlot(threadName, ImVec2(-1, 0), ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_NoBoxSelect | ImPlotFlags_NoMouseText))
|
||||
{
|
||||
float values[FC_PROFILE_HISTORY_MAX_SIZE];
|
||||
float max = FLT_MIN;
|
||||
for (int i = 0; i < FC_PROFILE_HISTORY_MAX_SIZE; i++)
|
||||
{
|
||||
values[i] = profileThread.history[i] * 1000.0f;
|
||||
if (values[i] > max)
|
||||
max = values[i];
|
||||
}
|
||||
|
||||
ImPlot::SetupAxis(ImAxis_X1, "Frame");
|
||||
ImPlot::SetupAxis(ImAxis_Y1, "Time (ms)");
|
||||
ImPlot::SetupAxesLimits(0, FC_PROFILE_HISTORY_MAX_SIZE, 0.0f, max, ImGuiCond_Always);
|
||||
ImPlot::PlotLine(threadName, values, FC_PROFILE_HISTORY_MAX_SIZE, 1.0f, 0.0f, ImPlotLineFlags_Shaded, profileThread.historyIdx);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ namespace fc_profiler
|
|||
void startThread(const std::string& threadName);
|
||||
void endThread(double warningTime = 0.0);
|
||||
void drawGUI(const std::vector<ProfileThread::ResultNode>& results);
|
||||
void drawGraph(const ProfileThread& profileThread);
|
||||
void outputTTY(const std::vector<ProfileThread::ResultNode>& results);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "lua/lua.h"
|
||||
#include "gui_chat.h"
|
||||
#include "imgui_driver.h"
|
||||
#include "implot/implot.h"
|
||||
#include "boxart/boxart.h"
|
||||
#include "profiler/fc_profiler.h"
|
||||
#if defined(USE_SDL)
|
||||
|
@ -103,6 +104,9 @@ void gui_init()
|
|||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
#if FC_PROFILER
|
||||
ImPlot::CreateContext();
|
||||
#endif
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
|
||||
io.IniFilename = NULL;
|
||||
|
@ -2879,6 +2883,11 @@ void gui_display_profiler()
|
|||
}
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
for (const fc_profiler::ProfileThread* profileThread : fc_profiler::ProfileThread::s_allThreads)
|
||||
{
|
||||
fc_profiler::drawGraph(*profileThread);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
|
|
Loading…
Reference in New Issue