Add benchmark. Looks slow :/
This commit is contained in:
27
Bench.cpp
Normal file
27
Bench.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include "Facade.h"
|
||||||
|
|
||||||
|
#include <nanobench.h>
|
||||||
|
|
||||||
|
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<int64_t>(0, facade.getVersion() - kWindow / 2))
|
||||||
|
.rangeRead({}, {0xff}, 0, false);
|
||||||
|
facade.setOldestVersion(
|
||||||
|
std::max<int64_t>(0, facade.getVersion() - kWindow));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() { monotonicallyIncreasing(); }
|
@@ -189,6 +189,10 @@ if(BUILD_TESTING)
|
|||||||
add_test(NAME versioned_map_blackbox_${hash} COMMAND driver ${TEST})
|
add_test(NAME versioned_map_blackbox_${hash} COMMAND driver ${TEST})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
add_executable(bench Bench.cpp)
|
||||||
|
target_compile_options(bench PRIVATE ${TEST_FLAGS})
|
||||||
|
target_link_libraries(bench PRIVATE ${PROJECT_NAME} nanobench)
|
||||||
|
|
||||||
# symbol visibility tests
|
# symbol visibility tests
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
Reference in New Issue
Block a user