Skip to content

Commit 9fef832

Browse files
committed
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%.
1 parent 153e686 commit 9fef832

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/bench/peer_eviction.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@ static void EvictionProtectionCommon(
2020
{
2121
using Candidates = std::vector<NodeEvictionCandidate>;
2222
FastRandomContext random_context{true};
23-
bench.warmup(100).epochIterations(1100);
2423

2524
Candidates candidates{GetRandomNodeEvictionCandidates(num_candidates, random_context)};
2625
for (auto& c : candidates) {
2726
candidate_setup_fn(c);
2827
}
2928

30-
std::vector<Candidates> copies{
31-
static_cast<size_t>(bench.epochs() * bench.epochIterations()), candidates};
32-
size_t i{0};
29+
3330
bench.run([&] {
34-
ProtectEvictionCandidatesByRatio(copies.at(i));
35-
++i;
31+
// creating a copy has an overhead of about 3%, so it does not influence the benchmark results much.
32+
auto copy = candidates;
33+
ProtectEvictionCandidatesByRatio(copy);
3634
});
3735
}
3836

0 commit comments

Comments
 (0)