From 58a2fa9868b226618085eb96d07f8aa02a83db90 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 19 Apr 2019 01:57:31 -0700 Subject: [PATCH] txscript: Add benchmark for IsPayToWitnessScriptHash --- txscript/bench_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/txscript/bench_test.go b/txscript/bench_test.go index de6636d9e7..529d32f7ff 100644 --- a/txscript/bench_test.go +++ b/txscript/bench_test.go @@ -297,3 +297,18 @@ func BenchmarkIsWitnessPubKeyHash(b *testing.B) { _ = IsPayToWitnessPubKeyHash(script) } } + +// BenchmarkIsWitnessScriptHash benchmarks how long it takes to analyze a very +// large script to determine if it is a standard witness script hash script. +func BenchmarkIsWitnessScriptHash(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++ { + _ = IsPayToWitnessScriptHash(script) + } +}