From 2b5edd2b5e32a3375f971fb0cce10f21ed7e7201 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 13 Mar 2019 01:11:25 -0500 Subject: [PATCH] txscript: Add benchmark for IsPushOnlyScript. --- txscript/bench_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/txscript/bench_test.go b/txscript/bench_test.go index 41d79ccb..ca64267a 100644 --- a/txscript/bench_test.go +++ b/txscript/bench_test.go @@ -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) + } +}