mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 10:31:16 +00:00
Enable callgrind for specific scenarios (#276)
This commit is contained in:
parent
4c5b255471
commit
99c0d2d744
@ -488,6 +488,14 @@ if (ISLE_BUILD_APP)
|
||||
)
|
||||
target_compile_definitions(isle PRIVATE ISLE_DEBUG)
|
||||
target_link_libraries(isle PRIVATE imgui)
|
||||
find_path(valgrind_INCLUDE_PATH NAMES valgrind/callgrind.h)
|
||||
if(valgrind_INCLUDE_PATH)
|
||||
# Run isle under valgrind to create a profile. Use e.g. kcachegrind to view the profile.
|
||||
# > valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes \
|
||||
# > --collect-atstart=no --instr-atstart=no ./isle --debug
|
||||
target_compile_definitions(isle PRIVATE ISLE_VALGRIND)
|
||||
target_include_directories(isle PRIVATE ${valgrind_INCLUDE_PATH})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@ -16,6 +16,10 @@
|
||||
#include <backends/imgui_impl_sdlrenderer3.h>
|
||||
#include <imgui.h>
|
||||
|
||||
#ifdef ISLE_VALGRIND
|
||||
#include <valgrind/callgrind.h>
|
||||
#endif
|
||||
|
||||
#define SCANCODE_KEY_PAUSE SDL_SCANCODE_KP_0
|
||||
#define SCANCODE_KEY_RESUME SDL_SCANCODE_KP_PERIOD
|
||||
|
||||
@ -28,6 +32,10 @@ static SDL_Renderer* g_debugRenderer;
|
||||
static SDL_Texture* g_videoPalette;
|
||||
static IDirect3DRMMiniwinDevice* g_d3drmMiniwinDevice;
|
||||
|
||||
#ifdef ISLE_VALGRIND
|
||||
static bool g_instrumentationEnabled;
|
||||
#endif
|
||||
|
||||
class DebugViewer {
|
||||
public:
|
||||
static void InsidePlantManager()
|
||||
@ -257,6 +265,19 @@ void IsleDebug_Render()
|
||||
Lego()->Resume();
|
||||
}
|
||||
}
|
||||
#ifdef ISLE_VALGRIND
|
||||
if (ImGui::MenuItem(g_instrumentationEnabled ? "Disable instrumentation" : "Enable instrumentation")) {
|
||||
g_instrumentationEnabled = !g_instrumentationEnabled;
|
||||
if (g_instrumentationEnabled) {
|
||||
CALLGRIND_START_INSTRUMENTATION;
|
||||
CALLGRIND_TOGGLE_COLLECT;
|
||||
}
|
||||
else {
|
||||
CALLGRIND_TOGGLE_COLLECT;
|
||||
CALLGRIND_STOP_INSTRUMENTATION;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ImGui::EndMainMenuBar();
|
||||
ImGui::ShowDemoWindow(nullptr);
|
||||
LegoOmni* lego = Lego();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user