WIP: next hard fork #5
2 changed files with 14 additions and 13 deletions
|
@ -327,3 +327,17 @@ func BenchmarkIsNullDataScript(b *testing.B) {
|
|||
_ = IsNullData(script)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkIsUnspendable benchmarks how long it takes IsUnspendable to analyze
|
||||
// a very large script.
|
||||
func BenchmarkIsUnspendable(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++ {
|
||||
_ = IsUnspendable(script)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4334,16 +4334,3 @@ func TestIsUnspendable(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkIsUnspendable adds a benchmark to compare the time and allocations
|
||||
// necessary for the IsUnspendable function.
|
||||
func BenchmarkIsUnspendable(b *testing.B) {
|
||||
pkScriptToUse := []byte{0xa9, 0x14, 0x82, 0x1d, 0xba, 0x94, 0xbc, 0xfb, 0xa2, 0x57, 0x36, 0xa3, 0x9e, 0x5d, 0x14, 0x5d, 0x69, 0x75, 0xba, 0x8c, 0x0b, 0x42, 0x87}
|
||||
var res bool = false
|
||||
for i := 0; i < b.N; i++ {
|
||||
res = IsUnspendable(pkScriptToUse)
|
||||
}
|
||||
if res {
|
||||
b.Fatalf("Benchmark should never have res be %t\n", res)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue