txscript: Add benchmark for GetSigOpCount.

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

View file

@ -341,3 +341,18 @@ func BenchmarkIsUnspendable(b *testing.B) {
_ = IsUnspendable(script) _ = IsUnspendable(script)
} }
} }
// BenchmarkGetSigOpCount benchmarks how long it takes to count the signature
// operations of a very large script.
func BenchmarkGetSigOpCount(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++ {
_ = GetSigOpCount(script)
}
}