txscript: Add benchmark for IsPayToScriptHash.

This commit is contained in:
Dave Collins 2019-03-13 01:11:13 -05:00 committed by Olaoluwa Osuntokun
parent c771f4fb38
commit 665c29802e
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -159,3 +159,18 @@ func BenchmarkIsPubKeyHashScript(b *testing.B) {
_ = IsPayToPubKeyHash(script)
}
}
// BenchmarkIsPayToScriptHash benchmarks how long it takes IsPayToScriptHash to
// analyze a very large script.
func BenchmarkIsPayToScriptHash(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++ {
_ = IsPayToScriptHash(script)
}
}