txscript: Add benchmark for IsPayToWitnessScriptHash

This commit is contained in:
Conner Fromknecht 2019-04-19 01:57:31 -07:00 committed by Olaoluwa Osuntokun
parent 54d08ebd5f
commit 728ce1001d
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -297,3 +297,18 @@ func BenchmarkIsWitnessPubKeyHash(b *testing.B) {
_ = IsPayToWitnessPubKeyHash(script)
}
}
// BenchmarkIsWitnessScriptHash benchmarks how long it takes to analyze a very
// large script to determine if it is a standard witness script hash script.
func BenchmarkIsWitnessScriptHash(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++ {
_ = IsPayToWitnessScriptHash(script)
}
}