Implemented gperftools support

it allows you to profile cpu/memory under unix systems
This commit is contained in:
Yehonal
2017-03-11 02:49:48 +01:00
parent 693dc56bf1
commit b522a0cb72
5 changed files with 67 additions and 0 deletions

View File

@@ -75,6 +75,11 @@ if( UNIX )
find_package(Readline)
find_package(ZLIB)
find_package(BZip2)
if ( WITH_PERFTOOLS )
find_package(Gperftools)
endif()
endif()
if(NOT WITHOUT_GIT)

View File

@@ -5,5 +5,6 @@ option(USE_SCRIPTPCH "Use precompiled headers when compiling scripts"
option(USE_COREPCH "Use precompiled headers when compiling servers" 1)
option(WITH_WARNINGS "Show all warnings during compile" 0)
option(WITH_COREDEBUG "Include additional debug-code in core" 0)
option(WITH_PERFTOOLS "Enable compilation with gperftools libraries included" 0)
option(WITH_MESHEXTRACTOR "Build meshextractor (alpha)" 0)
option(WITHOUT_GIT "Disable the GIT testing routines" 0)

View File

@@ -0,0 +1,51 @@
# Tries to find Gperftools.
#
# Usage of this module as follows:
#
# find_package(Gperftools)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# Gperftools_ROOT_DIR Set this variable to the root installation of
# Gperftools if the module has problems finding
# the proper installation path.
#
# Variables defined by this module:
#
# GPERFTOOLS_FOUND System has Gperftools libs/headers
# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler)
# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers
find_library(GPERFTOOLS_TCMALLOC
NAMES tcmalloc
HINTS ${Gperftools_ROOT_DIR}/lib)
find_library(GPERFTOOLS_PROFILER
NAMES profiler
HINTS ${Gperftools_ROOT_DIR}/lib)
find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER
NAMES tcmalloc_and_profiler
HINTS ${Gperftools_ROOT_DIR}/lib)
find_path(GPERFTOOLS_INCLUDE_DIR
NAMES gperftools/heap-profiler.h
HINTS ${Gperftools_ROOT_DIR}/include)
set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Gperftools
DEFAULT_MSG
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR)
mark_as_advanced(
Gperftools_ROOT_DIR
GPERFTOOLS_TCMALLOC
GPERFTOOLS_PROFILER
GPERFTOOLS_TCMALLOC_AND_PROFILER
GPERFTOOLS_LIBRARIES
GPERFTOOLS_INCLUDE_DIR)

View File

@@ -65,6 +65,15 @@ else()
message("* Use coreside debug : No (default)")
endif()
if ( UNIX )
if( WITH_PERFTOOLS )
message("* Use unix gperftools : Yes")
add_definitions(-DPERF_TOOLS)
else()
message("* Use unix gperftools : No (default)")
endif()
endif( UNIX )
if( WIN32 )
if( USE_MYSQL_SOURCES )
message("* Use MySQL sourcetree : Yes (default)")

View File

@@ -174,6 +174,7 @@ target_link_libraries(worldserver
g3dlib
gsoap
Detour
${GPERFTOOLS_LIBRARIES}
${JEMALLOC_LIBRARY}
${READLINE_LIBRARY}
${TERMCAP_LIBRARY}