bench: Utilitze setup() in WalletBalance for marking caches dirty

WalletBalance benchmarks the balance computation function and should
exclude the setup step of (optionally) marking caches as dirty. Instead,
that is moved into setup().
This commit is contained in:
Ava Chow
2026-04-29 14:29:07 -07:00
parent 61412ef887
commit d672455d20

View File

@@ -53,11 +53,14 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
auto bal = GetBalance(wallet); // Cache
bench.run([&] {
if (set_dirty) wallet.MarkDirty();
bal = GetBalance(wallet);
if (add_mine) assert(bal.m_mine_trusted > 0);
});
bench.setup([&] {
if (set_dirty) wallet.MarkDirty();
})
.run([&] {
bal = GetBalance(wallet);
ankerl::nanobench::doNotOptimizeAway(bal);
assert(add_mine == (bal.m_mine_trusted > 0));
});
}
static void WalletBalanceDirty(benchmark::Bench& bench) { WalletBalance(bench, /*set_dirty=*/true, /*add_mine=*/true); }