Refactor how the speedtest is built (#35)

This commit is contained in:
Jeremy Rifkin 2023-09-17 23:12:03 -04:00 committed by GitHub
parent 734c84400c
commit 6dac6da7b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 89 deletions

View File

@ -11,20 +11,10 @@ jobs:
fail-fast: false
matrix:
compiler: [g++-11, clang++-14]
target: [Debug]
std: [11, 20]
config: [
"-DCPPTRACE_GET_SYMBOLS_WITH_LIBDWARF=On -DCPPTRACE_BUILD_SPEEDTEST_DWARF4=On",
"-DCPPTRACE_GET_SYMBOLS_WITH_LIBDWARF=On -DCPPTRACE_BUILD_SPEEDTEST_DWARF5=On"
-DSPEEDTEST_DWARF4=On,
-DSPEEDTEST_DWARF5=On
]
#exclude:
## TODO: Maybe a bug in dwarf5_ranges. b _dwarf_error_string
## DW_DLE_RNGLISTS_ERROR: rnglists table index of 2052 too large for table of 5 entries.
#- config: "-DCPPTRACE_GET_SYMBOLS_WITH_LIBDWARF=On -DCPPTRACE_BUILD_SPEEDTEST_DWARF5=On"
# compiler: clang++-14
## TODO: Currently slow. Need to investigate why.
#- config: "-DCPPTRACE_GET_SYMBOLS_WITH_LIBDWARF=On -DCPPTRACE_BUILD_SPEEDTEST_DWARF4=On"
# compiler: clang++-14
steps:
- uses: actions/checkout@v2
- name: dependencies
@ -33,18 +23,18 @@ jobs:
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_BUILD_TYPE=Release
make -j
mkdir -p ../test/speedtest/build
cd ../test/speedtest/build
cmake .. \
-DCMAKE_BUILD_TYPE=${{matrix.target}} \
-DCMAKE_CXX_COMPILER=${{matrix.compiler}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
${{matrix.config}} \
-DCPPTRACE_BACKTRACE_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/include/backtrace.h \
-DCPPTRACE_BUILD_SPEEDTEST=On
-DCMAKE_BUILD_TYPE=Debug \
${{matrix.config}}
make -j
- name: test
working-directory: build
working-directory: test/speedtest/build
run: |
./speedtest | python3 ../ci/speedtest.py ${{matrix.compiler}} ${{matrix.config}}
./speedtest | python3 ../../../ci/speedtest.py ${{matrix.compiler}} ${{matrix.config}}
performancetest-windows:
runs-on: windows-2019
@ -52,11 +42,6 @@ jobs:
fail-fast: false
matrix:
compiler: [cl, clang++]
target: [Debug]
std: [11, 20]
config: [
"-DCPPTRACE_GET_SYMBOLS_WITH_DBGHELP=On"
]
steps:
- uses: actions/checkout@v2
- name: Enable Developer Command Prompt
@ -65,14 +50,15 @@ jobs:
run: |
mkdir -p build
cd build
cmake .. `
-DCMAKE_BUILD_TYPE=Debug `
-DCMAKE_CXX_COMPILER=${{matrix.compiler}} `
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
${{matrix.config}} `
-DCPPTRACE_BUILD_SPEEDTEST=On
cmake .. -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_BUILD_TYPE=Release
msbuild .\cpptrace.sln
mkdir -p ../test/speedtest/build
cd ../test/speedtest/build
cmake .. `
-DCMAKE_BUILD_TYPE=Debug `
${{matrix.config}}
msbuild .\cpptrace-speedtest.sln
- name: test
working-directory: build
working-directory: test/speedtest/build
run: |
.\${{matrix.target}}\speedtest.exe | python3 ../ci/speedtest.py ${{matrix.config}}
.\Debug\speedtest.exe | python3 ../../../ci/speedtest.py ${{matrix.config}}

View File

@ -51,10 +51,6 @@ option(CPPTRACE_BUILD_TEST "" OFF)
option(CPPTRACE_BUILD_DEMO "" OFF)
option(CPPTRACE_BUILD_TEST_RDYNAMIC "" OFF)
option(CPPTRACE_BUILD_SPEEDTEST "" OFF)
option(CPPTRACE_BUILD_SPEEDTEST_DWARF4 "" OFF)
option(CPPTRACE_BUILD_SPEEDTEST_DWARF5 "" OFF)
option(CPPTRACE_USE_SYSTEM_LIBDWARF "" OFF)
option(CPPTRACE_SANITIZER_BUILD "" OFF)
@ -65,9 +61,6 @@ mark_as_advanced(
CPPTRACE_BUILD_TEST
CPPTRACE_BUILD_DEMO
CPPTRACE_BUILD_TEST_RDYNAMIC
CPPTRACE_BUILD_SPEEDTEST
CPPTRACE_BUILD_SPEEDTEST_DWARF4
CPPTRACE_BUILD_SPEEDTEST_DWARF5
CPPTRACE_USE_SYSTEM_LIBDWARF
CPPTRACE_SANITIZER_BUILD
)
@ -508,49 +501,3 @@ if(CPPTRACE_BUILD_DEMO)
)
endif()
endif()
if(CPPTRACE_BUILD_SPEEDTEST)
if(CPPTRACE_BUILD_SPEEDTEST_DWARF4)
check_cxx_compiler_flag("-gdwarf-4" HAS_DWARF4)
if(HAS_DWARF4)
add_compile_options("$<$<CONFIG:Debug>:-gdwarf-4>")
#target_compile_options(speedtest PRIVATE "$<$<CONFIG:Debug>:-gdwarf-4>")
#target_compile_options(googletest INTERFACE "$<$<CONFIG:Debug>:-gdwarf-4>")
endif()
endif()
if(CPPTRACE_BUILD_SPEEDTEST_DWARF5)
check_cxx_compiler_flag("-gdwarf-5" HAS_DWARF5)
if(HAS_DWARF5)
add_compile_options("$<$<CONFIG:Debug>:-gdwarf-5>")
#target_compile_options(speedtest PRIVATE "$<$<CONFIG:Debug>:-gdwarf-4>")
#target_compile_options(googletest INTERFACE "$<$<CONFIG:Debug>:-gdwarf-4>")
endif()
endif()
include(FetchContent)
FetchContent_Declare(
googletest
DOWNLOAD_EXTRACT_TIMESTAMP On
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
add_executable(speedtest test/speedtest.cpp)
target_compile_features(speedtest PRIVATE cxx_range_for cxx_constexpr cxx_nullptr cxx_static_assert)
target_link_libraries(
speedtest
PRIVATE
GTest::gtest_main
cpptrace
)
if(WIN32)
add_custom_command(
TARGET speedtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:speedtest> $<TARGET_FILE_DIR:speedtest>
COMMAND_EXPAND_LISTS
)
endif()
endif()

View File

@ -321,9 +321,6 @@ Testing:
- `CPPTRACE_BUILD_TEST` Build a small test program
- `CPPTRACE_BUILD_DEMO` Build a small demo program
- `CPPTRACE_BUILD_TEST_RDYNAMIC` Use `-rdynamic` when compiling the test program
- `CPPTRACE_BUILD_SPEEDTEST` Build a small speed test program
- `CPPTRACE_BUILD_SPEEDTEST_DWARF4`
- `CPPTRACE_BUILD_SPEEDTEST_DWARF5`
## Testing Methodology

View File

@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.8)
project(cpptrace-speedtest CXX)
option(SPEEDTEST_DWARF4 "" OFF)
option(SPEEDTEST_DWARF5 "" OFF)
include(CheckCXXCompilerFlag)
if(SPEEDTEST_DWARF4)
check_cxx_compiler_flag("-gdwarf-4" HAS_DWARF4)
if(HAS_DWARF4)
add_compile_options("$<$<CONFIG:Debug>:-gdwarf-4>")
#target_compile_options(speedtest PRIVATE "$<$<CONFIG:Debug>:-gdwarf-4>")
#target_compile_options(googletest INTERFACE "$<$<CONFIG:Debug>:-gdwarf-4>")
endif()
endif()
if(SPEEDTEST_DWARF5)
check_cxx_compiler_flag("-gdwarf-5" HAS_DWARF5)
if(HAS_DWARF5)
add_compile_options("$<$<CONFIG:Debug>:-gdwarf-5>")
#target_compile_options(speedtest PRIVATE "$<$<CONFIG:Debug>:-gdwarf-4>")
#target_compile_options(googletest INTERFACE "$<$<CONFIG:Debug>:-gdwarf-4>")
endif()
endif()
include(FetchContent)
FetchContent_Declare(
googletest
DOWNLOAD_EXTRACT_TIMESTAMP On
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
set(cpptrace_DIR "../../build/cpptrace")
find_package(cpptrace REQUIRED)
add_executable(speedtest speedtest.cpp)
target_compile_features(speedtest PRIVATE cxx_std_11)
target_link_libraries(
speedtest
PRIVATE
GTest::gtest_main
cpptrace::cpptrace
)
if(WIN32)
add_custom_command(
TARGET speedtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:speedtest> $<TARGET_FILE_DIR:speedtest>
COMMAND_EXPAND_LISTS
)
endif()