txscript: Add benchmark IsPayToWitnessPubkeyHash

This commit is contained in:
Conner Fromknecht 2019-04-19 01:43:18 -07:00 committed by Olaoluwa Osuntokun
parent 2d5f7cf825
commit e422d42d7f
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -282,3 +282,18 @@ func BenchmarkIsPushOnlyScript(b *testing.B) {
_ = IsPushOnlyScript(script) _ = IsPushOnlyScript(script)
} }
} }
// BenchmarkIsWitnessPubKeyHash benchmarks how long it takes to analyze a very
// large script to determine if it is a standard witness pubkey hash script.
func BenchmarkIsWitnessPubKeyHash(b *testing.B) {
script, err := genComplexScript()
if err != nil {
b.Fatalf("failed to create benchmark script: %v", err)
}
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = IsPayToWitnessPubKeyHash(script)
}
}