mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-30 13:43:34 +02:00
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%.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user