| 16 | #include <string> |
| 17 | |
| 18 | static void BenchGetMappedAS(benchmark::Bench& bench, std::span<const CNetAddr> addrs, bool check = true) |
| 19 | { |
| 20 | std::span<const std::byte> asmap{node::data::ip_asn}; |
| 21 | assert(!asmap.empty() && CheckStandardAsmap(asmap)); |
| 22 | auto netgroupman{NetGroupManager::WithEmbeddedAsmap(asmap)}; |
| 23 | |
| 24 | bench.batch(addrs.size()).run([&] { |
| 25 | for (const CNetAddr& addr : addrs) { |
| 26 | // The embedded ASMap file might change over time and cause some |
| 27 | // addresses to become unmapped. We check the mapping to ensure |
| 28 | // the addresses are actually mapped. |
| 29 | assert((netgroupman.GetMappedAS(addr) > 0) == check); |
| 30 | } |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | static CNetAddr LookupAddr(const std::string& address) { return LookupHost(address, /*fAllowLookup=*/false).value(); } |
| 35 |
no test coverage detected