Skip to content

Commit

Permalink
Compile some files with -O2 even in Debug mode
Browse files Browse the repository at this point in the history
These files are responsible for most of the runtime in Debug mode.
Apply some optimizations to them even in Debug mode to get reasonable performance.

Timedemo on my machine goes from 40s down to 25s.
  • Loading branch information
glebm committed Sep 10, 2023
1 parent 0a78af4 commit a51abc4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ set(libdevilutionx_SRCS
utils/timer.cpp
utils/utf8.cpp)

# These files are responsible for most of the runtime in Debug mode.
# Apply some optimizations to them even in Debug mode to get reasonable performance.
set(_optimize_in_debug_srcs
engine/render/clx_render.cpp
engine/render/dun_render.cpp
engine/render/text_render.cpp
utils/cel_to_clx.cpp
utils/cl2_to_clx.cpp
utils/pcx_to_clx.cpp)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set_source_files_properties(${_optimize_in_debug_srcs} PROPERTIES COMPILE_OPTIONS "-O2")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_source_files_properties(${_optimize_in_debug_srcs} PROPERTIES COMPILE_OPTIONS "$<$<CONFIG:Debug>:/O2>")
endif()

if(SUPPORTS_MPQ)
list(APPEND libdevilutionx_DEPS libmpq)
list(APPEND libdevilutionx_SRCS
Expand Down

0 comments on commit a51abc4

Please sign in to comment.