| 14 | #include <vector> |
| 15 | |
| 16 | static 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 |
no test coverage detected