From bbaec903666baa4ff23779b77261cc4461685c3d Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 30 May 2021 02:55:37 -0500 Subject: [PATCH] stdscript: Add v0 nulldata benchmark. BenchmarkIsNullDataScript ------------------------- v0_complex_non_standard 279362058 4.306 ns/op 0 allocs/op v0_nulldata_no_data_push 276928082 4.325 ns/op 0 allocs/op v0_nulldata_single_zero_push 40513850 29.47 ns/op 0 allocs/op v0_nulldata_small_int_push 39842752 29.65 ns/op 0 allocs/op v0_nulldata_max_small_int_push 36889138 29.82 ns/op 0 allocs/op v0_nulldata_small_data_push 40597321 28.86 ns/op 0 allocs/op v0_nulldata_60-byte_push 41307235 28.68 ns/op 0 allocs/op v0_nulldata_max_standard_push 36347774 32.41 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/staging/stdscript/script_bench_test.go b/internal/staging/stdscript/script_bench_test.go index cd8a8d8d..8e428554 100644 --- a/internal/staging/stdscript/script_bench_test.go +++ b/internal/staging/stdscript/script_bench_test.go @@ -184,3 +184,12 @@ func BenchmarkMultiSigRedeemScriptFromScriptSigV0(b *testing.B) { }) } } + +// BenchmarkIsNullDataScript benchmarks the performance of analyzing various +// public key scripts to determine if they are nulldata scripts. +func BenchmarkIsNullDataScript(b *testing.B) { + filterFn := func(test scriptTest) bool { + return test.wantType == STNullData + } + benchIsX(b, filterFn, IsNullDataScript) +}