bench_test.go raw
1 package blockchain
2
3 import (
4 "github.com/p9c/p9/pkg/block"
5 "testing"
6 )
7
8 // BenchmarkIsCoinBase performs a simple benchmark against the IsCoinBase function.
9 func BenchmarkIsCoinBase(b *testing.B) {
10 tx, _ := block.NewBlock(&Block100000).Tx(1)
11 b.ResetTimer()
12 for i := 0; i < b.N; i++ {
13 IsCoinBase(tx)
14 }
15 }
16
17 // BenchmarkIsCoinBaseTx performs a simple benchmark against the IsCoinBaseTx function.
18 func BenchmarkIsCoinBaseTx(b *testing.B) {
19 tx := Block100000.Transactions[1]
20 b.ResetTimer()
21 for i := 0; i < b.N; i++ {
22 IsCoinBaseTx(tx)
23 }
24 }
25