With #28792 merged, we can use the embedded ASMap file to benchmark the IP -> ASN lookups. Before, this would have been cumbersome as it required having a real, external ASMap file. We want to benchmark against a real file, as a smaller test file has significantly faster lookups.
The benchmarks cover individual IP address lookups of mapped and unmapped IPv4 and IPv6 addresses along with a multi-IP lookup. For the IPs we assume to be mapped, we assert that they are mapped. Updating the embedded ASMap file might change the benchmark results slightly as some lookups will be a bit faster and others slower.
$ ./build/bin/bench_bitcoin --filter=ASMapGetMappedAS.* -min-time=5000
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 460.41 | 2,171,994.61 | 0.2% | 5.48 | `ASMapGetMappedASCloudflarev4`
| 356.96 | 2,801,460.45 | 0.0% | 5.33 | `ASMapGetMappedASCloudflarev6`
| 476.58 | 2,098,304.01 | 0.1% | 5.51 | `ASMapGetMappedASGooglev4`
| 359.17 | 2,784,224.15 | 0.0% | 5.33 | `ASMapGetMappedASGooglev6`
| 398.82 | 2,507,410.35 | 0.1% | 5.50 | `ASMapGetMappedASMulti`
| 346.11 | 2,889,237.31 | 0.3% | 5.32 | `ASMapGetMappedASQuad9v4`
| 274.21 | 3,646,832.70 | 0.1% | 5.50 | `ASMapGetMappedASQuad9v6`
| 5.32 | 187,875,440.96 | 0.1% | 5.50 | `ASMapGetMappedASUnmappedv4`
| 65.19 | 15,339,680.04 | 0.1% | 5.51 | `ASMapGetMappedASUnmappedv6`
LLM disclosure: while I wrote the initial benchmarks, I had a LLM review it and point out style nits and typos to me.