Skip to content

Commit

Permalink
txscript: Add benchmark IsPayToWitnessPubkeyHash
Browse files Browse the repository at this point in the history
  • Loading branch information
cfromknecht committed Feb 5, 2021
1 parent 29dcb83 commit c1d1b0e
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 @@ -282,3 +282,18 @@ func BenchmarkIsPushOnlyScript(b *testing.B) {
_ = IsPushOnlyScript(script)
}
}

// BenchmarkIsWitnessPubKeyHash benchmarks how long it takes to analyze a very
// large script to determine if it is a standard witness pubkey hash script.
func BenchmarkIsWitnessPubKeyHash(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++ {
_ = IsPayToWitnessPubKeyHash(script)
}
}

0 comments on commit c1d1b0e

Please sign in to comment.