As there are ongoing changes to the Silent Payments public key extraction function GetPubKeyFromInput (see recently merged #36338, upcoming #36417), it seems reasonable to add benchmarks for it. The first commit covers the standard shape of each eligible input type (P2PKH, P2SH-P2WPKH, P2WPKH and P2TR key-path spend; see BIP-352). The second adds a worst-case P2PKH input with a maximally malleated scriptSig, where every push has to be hashed during the scan.
Results on my arm64 machine (as per $ ./build/bin/bench_bitcoin -filter='BIP352_.*'):
| ns/input | input/s | err% | total | benchmark | |
|---|---|---|---|---|---|
| 3,034.12 | 329,584.35 | 0.2% | 0.01 | BIP352_GetPubKey_P2PKH |
|
| 69,868.20 | 14,312.66 | 0.1% | 0.01 | BIP352_GetPubKey_P2PKH_WorstCase |
|
| 2,841.35 | 351,945.44 | 0.1% | 0.01 | BIP352_GetPubKey_P2SH_P2WPKH |
|
| 2,768.00 | 361,272.01 | 0.1% | 0.01 | BIP352_GetPubKey_P2TR |
|
| 2,757.57 | 362,637.66 | 0.0% | 0.01 | BIP352_GetPubKey_P2WPKH |