MCPcopy Create free account
hub / github.com/ElementsProject/elements / EvictionProtectionCommon

Function EvictionProtectionCommon

src/bench/peer_eviction.cpp:16–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include <vector>
15
16static void EvictionProtectionCommon(
17 benchmark::Bench& bench,
18 int num_candidates,
19 std::function<void(NodeEvictionCandidate&)> candidate_setup_fn)
20{
21 using Candidates = std::vector<NodeEvictionCandidate>;
22 FastRandomContext random_context{true};
23
24 Candidates candidates{GetRandomNodeEvictionCandidates(num_candidates, random_context)};
25 for (auto& c : candidates) {
26 candidate_setup_fn(c);
27 }
28
29
30 bench.run([&] {
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);
34 });
35}
36
37/* Benchmarks */
38

Calls 3

runMethod · 0.45

Tested by

no test coverage detected