Skip to content

Commit

Permalink
txscript: Add benchmark for IsPushOnlyScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
davecgh authored and cfromknecht committed Feb 5, 2021
1 parent 3cfdeca commit 1f2afc1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions txscript/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,18 @@ func BenchmarkIsMultisigSigScript(b *testing.B) {
}
}
}

// BenchmarkIsPushOnlyScript benchmarks how long it takes IsPushOnlyScript to
// analyze a very large script.
func BenchmarkIsPushOnlyScript(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++ {
_ = IsPushOnlyScript(script)
}
}

0 comments on commit 1f2afc1

Please sign in to comment.