aboutsummaryrefslogtreecommitdiff
path: root/src/bench
diff options
context:
space:
mode:
authorMartin Ankerl <martin.ankerl@gmail.com>2021-09-18 08:13:03 +0200
committerMartin Ankerl <martin.ankerl@gmail.com>2021-09-21 14:45:48 +0200
commit9fef8329322277d9c14c8df1867cb3c61477c431 (patch)
treeed0c31d867cc71a11d286796f41acbfa7820b2e9 /src/bench
parent153e6860e84df0a3d52e5a3b2fe9c37b5e0b029a (diff)
downloadbitcoin-9fef8329322277d9c14c8df1867cb3c61477c431.tar.xz
bench: make EvictionProtection.* work with any number of iterations
Moves copying of the setup into the benchmark loop so it is possible to run the loop for an arbitrary number of times. The overhead due to copying the candidates inside the loop is about 3%.
Diffstat (limited to 'src/bench')
-rw-r--r--src/bench/peer_eviction.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/bench/peer_eviction.cpp b/src/bench/peer_eviction.cpp
index 46fd9d999e..8429f18613 100644
--- a/src/bench/peer_eviction.cpp
+++ b/src/bench/peer_eviction.cpp
@@ -20,19 +20,17 @@ static void EvictionProtectionCommon(
{
using Candidates = std::vector<NodeEvictionCandidate>;
FastRandomContext random_context{true};
- bench.warmup(100).epochIterations(1100);
Candidates candidates{GetRandomNodeEvictionCandidates(num_candidates, random_context)};
for (auto& c : candidates) {
candidate_setup_fn(c);
}
- std::vector<Candidates> copies{
- static_cast<size_t>(bench.epochs() * bench.epochIterations()), candidates};
- size_t i{0};
+
bench.run([&] {
- ProtectEvictionCandidatesByRatio(copies.at(i));
- ++i;
+ // creating a copy has an overhead of about 3%, so it does not influence the benchmark results much.
+ auto copy = candidates;
+ ProtectEvictionCandidatesByRatio(copy);
});
}