Skip to content

Commit

Permalink
txscript: Add benchmark for PushedData.
Browse files Browse the repository at this point in the history
  • Loading branch information
davecgh authored and cfromknecht committed Feb 5, 2021
1 parent 1df85f4 commit 5079460
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions txscript/bench_test.go
Expand Up @@ -438,3 +438,21 @@ func BenchmarkGetScriptClass(b *testing.B) {
_ = 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)
}
}
}

0 comments on commit 5079460

Please sign in to comment.