From 63cc0851e5bee7fe6152ace2c46fd796b1b08ca6 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 6 Nov 2013 16:21:49 -0600 Subject: [PATCH] Add benchmarks for writeTxIn. This commit adds a benchmark for the writeTxIn function. --- bench_test.go | 9 +++++++++ internal_test.go | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/bench_test.go b/bench_test.go index 82f895b7..377ab0aa 100644 --- a/bench_test.go +++ b/bench_test.go @@ -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) + } +} diff --git a/internal_test.go b/internal_test.go index 0696c200..e8ec3535 100644 --- a/internal_test.go +++ b/internal_test.go @@ -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) +}