29 auto randAddr = [&rng]() {
31 memcpy(&addr, rng.
randbytes(
sizeof(addr)).data(),
sizeof(addr));
34 memcpy(&port, rng.
randbytes(
sizeof(port)).data(),
sizeof(port));
46 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
57 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
90 const auto& address = addrman.
Select();
91 assert(address.GetPort() > 0);
102 const auto& addresses = addrman.
GetAddr( 2500, 23, std::nullopt);
103 assert(addresses.size() > 0);
117 for (
auto& addrman : addrmans) {
121 auto markSomeAsGood = [](
CAddrMan& addrman) {
122 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
124 if (addr_i % 32 == 0) {
133 markSomeAsGood(addrmans.at(i));
static constexpr size_t NUM_SOURCES
Bench & epochIterations(uint64_t numIters) noexcept
Sets exactly the number of iterations for each epoch.
static constexpr size_t NUM_ADDRESSES_PER_SOURCE
static void AddrManAdd(benchmark::Bench &bench)
void Clear() EXCLUSIVE_LOCKS_REQUIRED(!cs)
static std::vector< CAddress > g_sources
Stochastical (IP) address manager.
static void AddAddressesToAddrMan(CAddrMan &addrman)
std::vector< CAddress > GetAddr(size_t max_addresses, size_t max_pct, std::optional< Network > network) EXCLUSIVE_LOCKS_REQUIRED(!cs)
Return all or many randomly selected addresses, optionally by network.
CAddrInfo Select(bool newOnly=false) EXCLUSIVE_LOCKS_REQUIRED(!cs)
Choose an address to connect to.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
bool Add(const CAddress &addr, const CNetAddr &source, int64_t nTimePenalty=0) EXCLUSIVE_LOCKS_REQUIRED(!cs)
Add a single address.
A combination of a network address (CNetAddr) and a (TCP) port.
static void FillAddrMan(CAddrMan &addrman)
A CService with information about it as peer.
static std::vector< std::vector< CAddress > > g_addresses
Bench & epochs(size_t numEpochs) noexcept
Controls number of epochs, the number of measurements to perform.
int64_t GetAdjustedTime()
static void AddrManGetAddr(benchmark::Bench &bench)
static void AddrManSelect(benchmark::Bench &bench)
Main entry point to nanobench's benchmarking facility.
static void CreateAddresses()
uint32_t nTime
Always included in serialization, except in the network format on INIT_PROTO_VERSION.
static void AddrManGood(benchmark::Bench &bench)
std::vector< unsigned char > randbytes(size_t len)
Generate random bytes.