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

Function AddrManAddThenGood

src/bench/addrman.cpp:109–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109static 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
135BENCHMARK(AddrManAdd);
136BENCHMARK(AddrManSelect);

Callers

nothing calls this directly

Calls 4

CreateAddressesFunction · 0.85
AddAddressesToAddrManFunction · 0.85
GoodMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected