github.com/lbryio/lbcd@v0.22.119/blockchain/bench_test.go (about)

     1  // Copyright (c) 2015 The btcsuite developers
     2  // Use of this source code is governed by an ISC
     3  // license that can be found in the LICENSE file.
     4  
     5  package blockchain
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  // BenchmarkIsCoinBase performs a simple benchmark against the IsCoinBase
    12  // function.
    13  func BenchmarkIsCoinBase(b *testing.B) {
    14  	tx, _ := GetBlock100000().Tx(1)
    15  	b.ResetTimer()
    16  	for i := 0; i < b.N; i++ {
    17  		IsCoinBase(tx)
    18  	}
    19  }
    20  
    21  // BenchmarkIsCoinBaseTx performs a simple benchmark against the IsCoinBaseTx
    22  // function.
    23  func BenchmarkIsCoinBaseTx(b *testing.B) {
    24  	tx, _ := GetBlock100000().Tx(1)
    25  	b.ResetTimer()
    26  	for i := 0; i < b.N; i++ {
    27  		IsCoinBaseTx(tx.MsgTx())
    28  	}
    29  }