Add benchmarks for writeTxIn.

This commit adds a benchmark for the writeTxIn function.
This commit is contained in:
Dave Collins 2013-11-06 16:21:49 -06:00
parent 59da692131
commit 63cc0851e5
2 changed files with 15 additions and 0 deletions

View file

@ -192,3 +192,12 @@ func BenchmarkReadTxIn(b *testing.B) {
btcwire.TstReadTxIn(bytes.NewBuffer(buf), 0, 0, &txIn)
}
}
// BenchmarkWriteTxIn performs a benchmark on how long it takes to write
// a transaction input.
func BenchmarkWriteTxIn(b *testing.B) {
txIn := blockOne.Transactions[0].TxIn[0]
for i := 0; i < b.N; i++ {
btcwire.TstWriteTxIn(ioutil.Discard, 0, 0, txIn)
}
}

View file

@ -132,3 +132,9 @@ func TstWriteTxOut(w io.Writer, pver uint32, version uint32, to *TxOut) error {
func TstReadTxIn(r io.Reader, pver uint32, version uint32, ti *TxIn) error {
return readTxIn(r, pver, version, ti)
}
// TstWriteTxIn makes the internal writeTxIn function available to the test
// package.
func TstWriteTxIn(w io.Writer, pver uint32, version uint32, ti *TxIn) error {
return writeTxIn(w, pver, version, ti)
}