WIP: next hard fork #5
1 changed files with 38 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
|
@ -497,3 +498,40 @@ func BenchmarkExtractAtomicSwapDataPushes(b *testing.B) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkExtractPkScriptAddrsLarge benchmarks how long it takes to analyze
|
||||
// and potentially extract addresses from a very large non-standard script.
|
||||
func BenchmarkExtractPkScriptAddrsLarge(b *testing.B) {
|
||||
script, err := genComplexScript()
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create benchmark script: %v", err)
|
||||
}
|
||||
|
||||
params := &chaincfg.MainNetParams
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, _, _, err := ExtractPkScriptAddrs(script, params)
|
||||
if err != nil {
|
||||
b.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkExtractPkScriptAddrs benchmarks how long it takes to analyze and
|
||||
// potentially extract addresses from a typical script.
|
||||
func BenchmarkExtractPkScriptAddrs(b *testing.B) {
|
||||
script := mustParseShortForm("OP_DUP HASH160 " +
|
||||
"DATA_20 0x0102030405060708090a0b0c0d0e0f1011121314 " +
|
||||
"EQUAL")
|
||||
|
||||
params := &chaincfg.MainNetParams
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, _, _, err := ExtractPkScriptAddrs(script, params)
|
||||
if err != nil {
|
||||
b.Fatalf("unexpected err: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue