Skip to content

Instantly share code, notes, and snippets.

@lhog
Created January 30, 2022 23:59
Show Gist options
  • Save lhog/0f3c3b93330b6347525b7d772a179582 to your computer and use it in GitHub Desktop.
Save lhog/0f3c3b93330b6347525b7d772a179582 to your computer and use it in GitHub Desktop.
COZ profiler by pako
1st add: find_package(coz-profiler), add library dl, include coz.h and COZ_PROGRESS; in gameFrame()
2nd: compile with clang RelwithDebug or maybe gcc with some correct -gdwarf-4 settings
3rd: run: "coz run --- ./spring ./demos/2022xxx.sdfz"
4th: use /skip 10000 to profile synced code and maybe pause to profile drawing
From a6cfcbd9141146a5c84c38182a4cd6086608947e Mon Sep 17 00:00:00 2001
From: You Name <your@example.com>
Date: Sat, 29 Jan 2022 19:39:54
Subject: [PATCH] cozzz1
---
CMakeLists.txt | 2 ++
rts/Game/Game.cpp | 12 +++++++++++-
rts/builds/legacy/CMakeLists.txt | 2 ++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2b60a3a7e7..f0257dad74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -251,6 +251,8 @@ endif (USE_LIBSQUISH)
# So req. checks are done in the build target's CMakeLists.txt.
find_package(SDL2)
+##find_package(coz-profiler)
+
find_package_static(DevIL)
if (PREFER_STATIC_LIBS)
# dependencies of DevIL
diff --git a/rts/Game/Game.cpp b/rts/Game/Game.cpp
index bbd1ec04be..e660fc6306 100644
--- a/rts/Game/Game.cpp
+++ b/rts/Game/Game.cpp
@@ -121,6 +121,7 @@
#include "System/Sync/DumpState.h"
#include "System/TimeProfiler.h"
+#include "coz.h"
#undef CreateDirectory
@@ -1473,6 +1474,8 @@ void CGame::StartPlaying()
void CGame::SimFrame() {
+ //COZ_PROGRESS_NAMED("simframe_start");
+ COZ_PROGRESS;
ENTER_SYNCED_CODE();
ASSERT_SYNCED(gsRNG.GetGenState());
@@ -1516,15 +1519,22 @@ void CGame::SimFrame() {
// (fixed 30Hz gc is not enough while catching up)
if (luaGCControl == 0)
eventHandler.CollectGarbage(false);
-
+COZ_BEGIN("eventHandler.GameFrame(gs->frameNum);");
eventHandler.GameFrame(gs->frameNum);
+ COZ_END("eventHandler.GameFrame(gs->frameNum);");
}
helper->Update();
mapDamage->Update();
+ // COZ_BEGIN("pathManager->Update();");
pathManager->Update();
+ // COZ_END("pathManager->Update();");
+ // COZ_BEGIN("unitHandler.Update");
unitHandler.Update();
+ // COZ_END("unitHandler.Update");
+ // COZ_BEGIN("projectileHandler.Update();");
projectileHandler.Update();
+ //COZ_END("projectileHandler.Update();");
featureHandler.Update();
{
SCOPED_TIMER("Sim::Script");
diff --git a/rts/builds/legacy/CMakeLists.txt b/rts/builds/legacy/CMakeLists.txt
index 90ab97c5aa..1796f8dbf3 100644
--- a/rts/builds/legacy/CMakeLists.txt
+++ b/rts/builds/legacy/CMakeLists.txt
@@ -20,6 +20,7 @@ endif()
set(OpenGL_GL_PREFERENCE LEGACY)
find_package_static(OpenGL REQUIRED)
find_package_static(GLEW 1.5.1 REQUIRED)
+find_package(coz-profiler)
list(APPEND engineLibraries ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${GLEW_LIBRARIES})
list(APPEND engineIncludes ${GLEW_INCLUDE_DIR})
@@ -70,6 +71,7 @@ list(APPEND engineLibraries engineaGui)
list(APPEND engineLibraries ${SPRING_SIM_LIBRARIES})
list(APPEND engineLibraries engineSim)
list(APPEND engineLibraries pr-downloader_static)
+list(APPEND engineLibraries dl)
### Assemble external incude dirs
list(APPEND engineIncludes ${OPENAL_INCLUDE_DIR})
--
2.33.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment