chore: improve benchmark for bpptree and zsl tree (#2450)

* chore: improve benchmark for bpptree and zsl tree
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-01-22 09:33:45 +02:00 committed by GitHub
parent fab811252b
commit 307bdfdb07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -415,9 +415,13 @@ static void BM_FindRandomBPTree(benchmark::State& state) {
bptree.Insert(vals[i]);
}
while (state.KeepRunning()) {
for (unsigned i = 0; i < iters; ++i) {
benchmark::DoNotOptimize(bptree.Contains(vals[i]));
unsigned i = 0;
while (state.KeepRunningBatch(10)) {
for (unsigned j = 0; j < 10; ++j) {
benchmark::DoNotOptimize(bptree.GEQ(vals[i]));
++i;
if (vals.size() == i)
i = 0;
}
}
for (const auto v : vals) {
@ -434,9 +438,20 @@ static void BM_FindRandomZSL(benchmark::State& state) {
zslInsert(zsl, vals[i].d, sdsdup(vals[i].s));
}
while (state.KeepRunning()) {
for (unsigned i = 0; i < iters; ++i) {
benchmark::DoNotOptimize(zslGetRank(zsl, vals[i].d, vals[i].s));
zrangespec spec;
spec.maxex = 0;
spec.minex = 0;
unsigned i = 0;
while (state.KeepRunningBatch(10)) {
for (unsigned j = 0; j < 10; ++j) {
spec.min = vals[i].d;
spec.max = spec.min;
benchmark::DoNotOptimize(zslFirstInRange(zsl, &spec));
++i;
if (vals.size() == i)
i = 0;
}
}