forked from tilir/benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Konstantin Vladimirov
committed
Mar 1, 2024
1 parent
ed9a716
commit 2ecf18f
Showing
13 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.11) | ||
project("benchmarks") | ||
|
||
enable_testing() | ||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/CSVS) | ||
|
||
find_package(cppbenchmark REQUIRED) | ||
|
||
add_custom_target(runall) | ||
|
||
add_subdirectory(coro-fibs) | ||
add_subdirectory(excret) | ||
add_subdirectory(inline) | ||
add_subdirectory(noexcept-qsort) | ||
add_subdirectory(ranges-filter) | ||
add_subdirectory(ranges-projector) | ||
add_subdirectory(virtual-inline) | ||
add_subdirectory(virtual-overhead) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[requires] | ||
cppbenchmark/cci.20201029 | ||
[generators] | ||
CMakeDeps | ||
CMakeToolchain | ||
[layout] | ||
cmake_layout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SET(TNAME coro-fibs) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SET(TNAME exc_ret) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SET(TNAME extswap) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
SET(TNAME exc_qsort) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SET(TNAME filter) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SET(TNAME projector) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <algorithm> | ||
#include <random> | ||
#include <ranges> | ||
#include <vector> | ||
|
||
#include "benchmark/cppbenchmark.h" | ||
|
||
namespace ranges = std::ranges; | ||
namespace views = std::views; | ||
|
||
struct S { int x, y; }; | ||
|
||
constexpr int N = 100; | ||
constexpr int NBMK = 1000; | ||
|
||
class TestFixture { | ||
protected: | ||
std::vector<S> v; | ||
std::vector<int> w; | ||
std::random_device r; | ||
std::mt19937 g; | ||
|
||
TestFixture() : g(r()) { | ||
v.resize(N); | ||
w.resize(N); | ||
std::uniform_int_distribution<int> dist {0, 100}; | ||
auto gen = [&, this]() -> S { return {dist(g), dist(g)}; }; | ||
std::generate(std::begin(v), std::end(v), gen); | ||
} | ||
}; | ||
|
||
BENCHMARK_FIXTURE(TestFixture, "TransformComparator") { | ||
for (int i = 0; i < NBMK; ++i) | ||
ranges::transform(v.begin(), v.end(), w.begin(), [](const auto& a) { return a.x * 2; }); | ||
} | ||
|
||
BENCHMARK_FIXTURE(TestFixture, "TransformProjector") { | ||
for (int i = 0; i < NBMK; ++i) | ||
ranges::transform(v.begin(), v.end(), w.begin(), [](auto x) { return x * 2; }, &S::x); | ||
} | ||
|
||
BENCHMARK_MAIN() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SET(TNAME virtinh) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SET(TNAME virtinl) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
SET(TNAME virtual) | ||
|
||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
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 ${TNAME} -q -o csv > ${CMAKE_BINARY_DIR}/CSVS/${TNAME}.csv) | ||
set_tests_properties(${TEST_TARGET} PROPERTIES DEPENDS ${TNAME}) | ||
|