27 lines
1005 B
C++
27 lines
1005 B
C++
#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(); } |