From bc56df10463edbc86d10e4b1aa68fad63d2a3d2c Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 13 Mar 2019 01:11:23 -0500 Subject: [PATCH] txscript: Add benchmark for isAnyKindOfScriptHash. --- txscript/bench_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/txscript/bench_test.go b/txscript/bench_test.go index 40f79295..11275ba2 100644 --- a/txscript/bench_test.go +++ b/txscript/bench_test.go @@ -223,3 +223,18 @@ func BenchmarkGetSigOpCount(b *testing.B) { _ = GetSigOpCount(script) } } + +// BenchmarkIsAnyKindOfScriptHash benchmarks how long it takes to +// isAnyKindOfScriptHash to analyze operations of a very large script. +func BenchmarkIsAnyKindOfScriptHash(b *testing.B) { + script, err := genComplexScript() + if err != nil { + b.Fatalf("failed to create benchmark script: %v", err) + } + + b.ResetTimer() + for i := 0; i < b.N; i++ { + pops, _ := parseScript(script) + _ = isAnyKindOfScriptHash(pops) + } +}