From d672455d201583dbc66f03b831910028633da434 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Wed, 29 Apr 2026 14:29:07 -0700 Subject: [PATCH] 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(). --- src/bench/wallet_balance.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp index d9cd4bbb952..07fd46a9fca 100644 --- a/src/bench/wallet_balance.cpp +++ b/src/bench/wallet_balance.cpp @@ -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); }