10#include <test/util/net.h>
11#include <test/util/setup_common.h>
20 using Candidates = std::vector<NodeEvictionCandidate>;
23 Candidates candidates{
24 GetRandomNodeEvictionCandidates(num_candidates, random_context)};
25 for (
auto &c : candidates) {
26 candidate_setup_fn(c);
32 auto copy = candidates;
53 if (c.
id >= 130 && c.
id < 240) {
54 c.m_network = NET_ONION;
56 c.m_network = NET_IPV4;
66 if (c.
id >= 90 && c.
id < 160) {
68 c.m_network = NET_ONION;
69 }
else if (c.
id >= 170 && c.
id < 250) {
71 c.m_network = NET_I2P;
73 c.m_network = NET_IPV4;
84 if (c.
id >= 30 && c.
id < 47) {
87 }
else if (c.
id >= 24 && c.
id < 28) {
102 if (c.
id >= 70 && c.
id < 80) {
105 }
else if (c.
id >= 80 && c.
id < 96) {
120 if (c.
id >= 170 && c.
id < 180) {
123 }
else if (c.
id >= 190 && c.
id < 240) {
Main entry point to nanobench's benchmarking facility.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
void ProtectEvictionCandidatesByRatio(std::vector< NodeEvictionCandidate > &eviction_candidates)
Protect desirable or disadvantaged inbound peers from eviction by ratio.
@ NET_ONION
TOR (v2 or v3)
static void EvictionProtection2Networks250Candidates(benchmark::Bench &bench)
BENCHMARK(EvictionProtection0Networks250Candidates)
static void EvictionProtection3Networks100Candidates(benchmark::Bench &bench)
static void EvictionProtectionCommon(benchmark::Bench &bench, int num_candidates, std::function< void(NodeEvictionCandidate &)> candidate_setup_fn)
static void EvictionProtection1Networks250Candidates(benchmark::Bench &bench)
static void EvictionProtection3Networks250Candidates(benchmark::Bench &bench)
static void EvictionProtection0Networks250Candidates(benchmark::Bench &bench)
static void EvictionProtection3Networks050Candidates(benchmark::Bench &bench)
std::chrono::seconds m_connected