From 96a2bc60f67bd70b1ebbda18b95493916f9aab6e Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 30 May 2021 02:55:52 -0500 Subject: [PATCH] stdscript: Add v0 stake change p2sh benchmark. BenchmarkIsStakeChangeScriptHash -------------------------------- v0_complex_non_standard 688796947 1.626 ns/op 0 allocs/op v0_stake_change_p2sh 503956689 2.282 ns/op 0 allocs/op This is part of a series of commits to fully implement the stdscript package. --- internal/staging/stdscript/script_bench_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/staging/stdscript/script_bench_test.go b/internal/staging/stdscript/script_bench_test.go index f65e444f..fb259c66 100644 --- a/internal/staging/stdscript/script_bench_test.go +++ b/internal/staging/stdscript/script_bench_test.go @@ -262,3 +262,13 @@ func BenchmarkIsStakeChangePubKeyHash(b *testing.B) { } benchIsX(b, filterFn, IsStakeChangePubKeyHashScript) } + +// BenchmarkIsStakeChangeScriptHash benchmarks the performance of analyzing +// various public key scripts to determine if they are stake change p2sh +// scripts. +func BenchmarkIsStakeChangeScriptHash(b *testing.B) { + filterFn := func(test scriptTest) bool { + return test.wantType == STStakeChangeScriptHash + } + benchIsX(b, filterFn, IsStakeChangeScriptHashScript) +}