Add standalone bench target

This commit is contained in:
2024-02-06 15:03:54 -08:00
parent 9a80c96533
commit 6be23803a3
3 changed files with 51 additions and 26 deletions

View File

@@ -1178,30 +1178,6 @@ void __throw_length_error(const char *) { __builtin_unreachable(); }
} // namespace std
#ifdef ENABLE_MAIN
#define ANKERL_NANOBENCH_IMPLEMENT
#include "third_party/nanobench.h"
void bench() {
ankerl::nanobench::Bench bench;
{
auto *n = newNode();
for (int i = 0; i < 64; ++i) {
getOrCreateChild(n, i) = newNode();
bench.run("getChildLeq" + std::to_string(i),
[&]() { bench.doNotOptimizeAway(getChildLeq(n, 255)); });
}
destroyTree(n);
}
{
auto *n = newNode();
for (int i = 255; i >= 3 * 64; --i) {
getOrCreateChild(n, i) = newNode();
bench.run("getChildGeq" + std::to_string(i),
[&]() { bench.doNotOptimizeAway(getChildGeq(n, 0)); });
}
destroyTree(n);
}
}
void printTree() {
int64_t writeVersion = 0;
@@ -1224,8 +1200,7 @@ void printTree() {
}
int main(void) {
bench();
// printTree();
printTree();
return 0;
}
#endif