txscript: Add benchmark for PushedData.

This commit is contained in:
Dave Collins 2019-03-13 01:12:18 -05:00 committed by Olaoluwa Osuntokun
parent 7791f92f6f
commit c4f6302189
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -438,3 +438,21 @@ func BenchmarkGetScriptClass(b *testing.B) {
_ = GetScriptClass(script) _ = GetScriptClass(script)
} }
} }
// BenchmarkPushedData benchmarks how long it takes to extract the pushed data
// from a very large script.
func BenchmarkPushedData(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++ {
_, err := PushedData(script)
if err != nil {
b.Fatalf("unexpected err: %v", err)
}
}
}