From e422d42d7fdde45c222810363d24b8eb3340cf2a Mon Sep 17 00:00:00 2001
From: Conner Fromknecht <conner@lightning.engineering>
Date: Fri, 19 Apr 2019 01:43:18 -0700
Subject: [PATCH] txscript: Add benchmark IsPayToWitnessPubkeyHash

---
 txscript/bench_test.go | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/txscript/bench_test.go b/txscript/bench_test.go
index ca64267a..de6636d9 100644
--- a/txscript/bench_test.go
+++ b/txscript/bench_test.go
@@ -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)
+	}
+}