From 665c29802ed3b6034396e4195b2abad8c77d2ab5 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 13 Mar 2019 01:11:13 -0500 Subject: [PATCH] txscript: Add benchmark for IsPayToScriptHash. --- txscript/bench_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/txscript/bench_test.go b/txscript/bench_test.go index 401b9683..e47cf21f 100644 --- a/txscript/bench_test.go +++ b/txscript/bench_test.go @@ -159,3 +159,18 @@ func BenchmarkIsPubKeyHashScript(b *testing.B) { _ = IsPayToPubKeyHash(script) } } + +// BenchmarkIsPayToScriptHash benchmarks how long it takes IsPayToScriptHash to +// analyze a very large script. +func BenchmarkIsPayToScriptHash(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++ { + _ = IsPayToScriptHash(script) + } +}