diff --git a/Bench.cpp b/Bench.cpp new file mode 100644 index 0000000..3efa2d4 --- /dev/null +++ b/Bench.cpp @@ -0,0 +1,27 @@ +#include "Facade.h" + +#include + +void monotonicallyIncreasing() { + constexpr int kWindow = 100; + ankerl::nanobench::Bench bench; + Facade facade{0}; + bench.warmup(kWindow).run("monotonically increasing", [&] { + const int64_t remove = __builtin_bswap64(facade.getVersion() - kWindow); + const int64_t next = __builtin_bswap64(facade.getVersion()); + weaselab::VersionedMap::Mutation mutations[] = { + {(const uint8_t *)&remove, nullptr, 8, 0, + weaselab::VersionedMap::Clear}, + {(const uint8_t *)&next, (const uint8_t *)&next, 8, 8, + weaselab::VersionedMap::Set}, + }; + facade.addMutations(mutations, sizeof(mutations) / sizeof(mutations[0]), + facade.getVersion() + 1); + facade.viewAt(std::max(0, facade.getVersion() - kWindow / 2)) + .rangeRead({}, {0xff}, 0, false); + facade.setOldestVersion( + std::max(0, facade.getVersion() - kWindow)); + }); +} + +int main() { monotonicallyIncreasing(); } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 5278567..fc9a8fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,6 +189,10 @@ if(BUILD_TESTING) add_test(NAME versioned_map_blackbox_${hash} COMMAND driver ${TEST}) endforeach() + add_executable(bench Bench.cpp) + target_compile_options(bench PRIVATE ${TEST_FLAGS}) + target_link_libraries(bench PRIVATE ${PROJECT_NAME} nanobench) + # symbol visibility tests if(NOT CMAKE_BUILD_TYPE STREQUAL Debug) if(APPLE)