support coz profiling

This commit is contained in:
Tim Felgentreff 2020-11-22 09:42:39 +01:00
parent 694a8fc722
commit 6c5a25c316
4 changed files with 44 additions and 2 deletions

View file

@ -817,8 +817,14 @@ if(WIN32 AND MSVC)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Profile")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
find_package(coz-profiler)
if(COZ-PROFILER_FOUND)
add_definitions(-DHAVE_COZ_PROFILER)
include_directories(${COZ_INCLUDE_DIRS})
set(stratagus_LIBS ${stratagus_LIBS} ${COZ_LIBRARIES} -ldl)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg -g -ggdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg -g -ggdb")
endif()
# TODO: Add support for other compilers
@ -909,6 +915,11 @@ endif()
if(CMAKE_BUILD_TYPE STREQUAL "Profile")
message("Profiling mode: Yes (Disable by param -DCMAKE_BUILD_TYPE=Release)")
if(COZ-PROFILER_FOUND)
message("Coz profiler enabled build: Yes")
else()
message("Coz profiler enabled build: No")
endif()
else()
message("Profiling mode: No (Enable by param -DCMAKE_BUILD_TYPE=Profile)")
endif()

View file

@ -0,0 +1,23 @@
find_path(COZ_INCLUDE_DIRS NAMES coz.h)
find_library(COZ_LIBRARIES NAMES coz PATH_SUFFIXES coz-profiler)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(coz-profiler
DEFAULT_MSG
COZ_LIBRARIES
COZ_INCLUDE_DIRS)
if(COZ-PROFILER_FOUND)
add_library(coz::coz INTERFACE IMPORTED)
set_target_properties(coz::coz
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
${COZ_INCLUDE_DIRS}
INTERFACE_LINK_LIBRARIES
${COZ_LIBRARIES})
else(COZ-PROFILER_FOUND)
set(COZ_LIBRARIES)
set(COZ_INCLUDE_DIRS)
endif(COZ-PROFILER_FOUND)
mark_as_advanced(COZ_INCLUDE_DIRS COZ_LIBRARIES)

View file

@ -30,6 +30,10 @@
#ifndef __STRATAGUS_H__
#define __STRATAGUS_H__
#ifdef HAVE_COZ_PROFILER
#include <coz.h>
#endif
//@{
/*============================================================================

View file

@ -313,6 +313,10 @@ static void GameLogicLoop()
if (!NetworkInSync) {
NetworkRecover(); // recover network
}
#ifdef HAVE_COZ_PROFILER
COZ_PROGRESS_NAMED("GameLogicLoop")
#endif
}
//#define REALVIDEO