Add benchmark. Looks slow :/

This commit is contained in:
2024-05-22 13:14:25 -07:00
parent 49a1ec0ab7
commit 3e1bd9c7b8
2 changed files with 31 additions and 0 deletions

27
Bench.cpp Normal file
View 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(); }