More benchmarks
This commit is contained in:
51
Bench.cpp
51
Bench.cpp
@@ -6,6 +6,7 @@ void monotonicallyIncreasing() {
|
|||||||
constexpr int kWindow = 100;
|
constexpr int kWindow = 100;
|
||||||
ankerl::nanobench::Bench bench;
|
ankerl::nanobench::Bench bench;
|
||||||
Facade facade{0};
|
Facade facade{0};
|
||||||
|
|
||||||
bench.warmup(kWindow).run("monotonically increasing", [&] {
|
bench.warmup(kWindow).run("monotonically increasing", [&] {
|
||||||
const int64_t remove = __builtin_bswap64(facade.getVersion() - kWindow);
|
const int64_t remove = __builtin_bswap64(facade.getVersion() - kWindow);
|
||||||
const int64_t next = __builtin_bswap64(facade.getVersion());
|
const int64_t next = __builtin_bswap64(facade.getVersion());
|
||||||
@@ -17,11 +18,53 @@ void monotonicallyIncreasing() {
|
|||||||
};
|
};
|
||||||
facade.addMutations(mutations, sizeof(mutations) / sizeof(mutations[0]),
|
facade.addMutations(mutations, sizeof(mutations) / sizeof(mutations[0]),
|
||||||
facade.getVersion() + 1);
|
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));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const auto v = facade.getVersion() - kWindow / 2;
|
||||||
|
const auto begin = facade.versioned.begin(v);
|
||||||
|
const auto end = facade.versioned.end(v);
|
||||||
|
auto iter = begin;
|
||||||
|
|
||||||
|
// Slow because all the clears from old versions are still around.
|
||||||
|
bench.run("scan", [&] {
|
||||||
|
for (iter = begin; iter != end; ++iter) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bench.run("reverse scan", [&] {
|
||||||
|
iter = end;
|
||||||
|
do {
|
||||||
|
--iter;
|
||||||
|
} while (iter != begin);
|
||||||
|
});
|
||||||
|
|
||||||
|
bench.run("deref", [&] { bench.doNotOptimizeAway(*iter); });
|
||||||
|
|
||||||
|
iter = begin;
|
||||||
|
bench.run("++iter", [&] {
|
||||||
|
++iter;
|
||||||
|
if (iter == end) {
|
||||||
|
iter = begin;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
iter = end;
|
||||||
|
bench.run("--iter", [&] {
|
||||||
|
--iter;
|
||||||
|
if (iter == begin) {
|
||||||
|
iter = end;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bench.run("begin", [&] { facade.versioned.begin(v); });
|
||||||
|
|
||||||
|
bench.run("begin (firstGeq)", [&] {
|
||||||
|
weaselab::VersionedMap::Key key{nullptr, 0};
|
||||||
|
weaselab::VersionedMap::Iterator iter;
|
||||||
|
facade.versioned.firstGeq(&key, &v, &iter, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
bench.run("end", [&] { facade.versioned.end(v); });
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() { monotonicallyIncreasing(); }
|
int main() { monotonicallyIncreasing(); }
|
Reference in New Issue
Block a user