| 107 | } |
| 108 | |
| 109 | static void AddrManAddThenGood(benchmark::Bench& bench) |
| 110 | { |
| 111 | auto markSomeAsGood = [](AddrMan& addrman) { |
| 112 | for (size_t source_i = 0; source_i < NUM_SOURCES; ++source_i) { |
| 113 | for (size_t addr_i = 0; addr_i < NUM_ADDRESSES_PER_SOURCE; ++addr_i) { |
| 114 | addrman.Good(g_addresses[source_i][addr_i]); |
| 115 | } |
| 116 | } |
| 117 | }; |
| 118 | |
| 119 | CreateAddresses(); |
| 120 | |
| 121 | bench.run([&] { |
| 122 | // To make the benchmark independent of the number of evaluations, we always prepare a new addrman. |
| 123 | // This is necessary because AddrMan::Good() method modifies the object, affecting the timing of subsequent calls |
| 124 | // to the same method and we want to do the same amount of work in every loop iteration. |
| 125 | // |
| 126 | // This has some overhead (exactly the result of AddrManAdd benchmark), but that overhead is constant so improvements in |
| 127 | // AddrMan::Good() will still be noticeable. |
| 128 | AddrMan addrman{EMPTY_ASMAP, /*deterministic=*/false, ADDRMAN_CONSISTENCY_CHECK_RATIO}; |
| 129 | AddAddressesToAddrMan(addrman); |
| 130 | |
| 131 | markSomeAsGood(addrman); |
| 132 | }); |
| 133 | } |
| 134 | |
| 135 | BENCHMARK(AddrManAdd); |
| 136 | BENCHMARK(AddrManSelect); |
nothing calls this directly
no test coverage detected