txscript: Add benchmark for GetScriptClass.

This commit is contained in:
Dave Collins 2019-03-13 01:11:32 -05:00 committed by Roy Lee
parent 43e2a2acb2
commit aa5a1d1648

View file

@ -423,3 +423,18 @@ func BenchmarkGetWitnessSigOpCountNested(b *testing.B) {
_ = GetWitnessSigOpCount(sigScript, pkScript, witness)
}
}
// BenchmarkGetScriptClass benchmarks how long it takes GetScriptClass to
// analyze a very large script.
func BenchmarkGetScriptClass(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++ {
_ = GetScriptClass(script)
}
}