Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional instructions for Windows + changed CMakeLists.txt #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions coro-fibs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ add_executable(${TNAME} corofibs.cc sumfib_module.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
# cannot use cmd here because of some strange things in path: https://gitlab.kitware.com/cmake/cmake/-/issues/17067
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()

set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})
36 changes: 28 additions & 8 deletions excret/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@ add_executable(${TNAME} exc_ret_1.cc exc_ret_2.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})


# same benchmark, version when no exception happened

SET(TNAME exc_ret_noexc)
Expand All @@ -21,8 +31,18 @@ target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)
target_compile_definitions(${TNAME} PUBLIC NOEXC)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})

17 changes: 13 additions & 4 deletions inline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ add_executable(${TNAME} extswap.cc partition.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})

36 changes: 28 additions & 8 deletions noexcept-qsort/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,42 @@ add_executable(${TNAME} exc_qsort.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})


SET(TNAME exc_partition)

add_executable(${TNAME} exc_partition.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})



18 changes: 14 additions & 4 deletions ranges-filter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ add_executable(${TNAME} filter.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})



18 changes: 14 additions & 4 deletions ranges-projector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ add_executable(${TNAME} projector.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})



19 changes: 17 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,29 @@ If you have custom compiler be sure it is inside profile.

Now you are ready for main build and run. Conan will download all dependencies for you.

```
## Linux build

```bash
conan install conanfile.txt --build=missing
cmake -S . -B build/Release --toolchain build/Release/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build/Release
env CTEST_OUTPUT_ON_FAILURE=1 cmake --build build/Release --target test --parallel 1
```

This will take some time, be patient. Benchmarking results will be created in the build/Release/CSVS folder.
## Windows build

It is highly recommended to use developer powershell

```pwsh
conan install conanfile.txt --build=missing
cmake -S . -B .\build --toolchain .\build\generators\conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW
cmake --build --preset conan-release
powershell -command { $env:CTEST_OUTPUT_ON_FAILURE='1'; cmake --build --preset conan-release --target RUN_TESTS --parallel 1 }
```

---

This will take some time, be patient. Benchmarking results will be created in the build/Release/CSVS folder for Linux and in build/CSVS folder for Windows.

You are welcome to create MR in results folder with your architecture and name it will help my talk!

Expand Down
18 changes: 14 additions & 4 deletions virtual-inherit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ add_executable(${TNAME} virtinh.cc fmodule.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()

set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})


18 changes: 14 additions & 4 deletions virtual-inline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ add_executable(${TNAME} virtinl.cc fmodule.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()

set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})


10 changes: 8 additions & 2 deletions virtual-inline/virtinl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
#include "benchmark/cppbenchmark.h"
#endif

#if defined(_WIN32) || defined(_WIN64)
#define NOINLINE __declspec(noinline)
#else
#define NOINLINE __attribute__((noinline))
#endif

constexpr int NCALL = 100;
constexpr int NBMK = 10000;

Expand Down Expand Up @@ -49,14 +55,14 @@ struct VirtDerived : VirtBase {
}
};

int __attribute__((noinline)) startup(NonVirt *nv) {
NOINLINE int startup(NonVirt *nv) {
int sum = 0;
for (int i = 0; i < NBMK; ++i)
sum += nv->bar(NCALL);
return sum;
}

int __attribute__((noinline)) startup(VirtBase *vb) {
NOINLINE int startup(VirtBase *vb) {
int sum = 0;
for (int i = 0; i < NBMK; ++i)
sum += vb->bar(NCALL);
Expand Down
38 changes: 30 additions & 8 deletions virtual-overhead/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,44 @@ add_executable(${TNAME} virtual-1.cc virtual-2.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()

set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})


SET(TNAME virtual-shuffle)

add_executable(${TNAME} virtual-shuffle-1.cc virtual-shuffle-2.cc)
target_compile_features(${TNAME} PRIVATE cxx_std_20)
target_link_libraries(${TNAME} cppbenchmark::cppbenchmark)

add_test(
NAME TEST_${TNAME}
COMMAND sh -c "./${TNAME} -q -o csv > ${CSVS}/${TNAME}.csv"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(TO_NATIVE_PATH "${CSVS}/${TNAME}.csv" CSV_OUT)

if (WIN32)
add_test(
NAME TEST_${TNAME}
COMMAND powershell -command "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
add_test(
NAME TEST_${TNAME}
COMMAND sh -c "$<TARGET_FILE:${TNAME}> -q -o csv > ${CSV_OUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()

set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME})