diff --git a/bench_test.go b/bench_test.go index f0e178ac..f17ac565 100644 --- a/bench_test.go +++ b/bench_test.go @@ -106,13 +106,29 @@ func BenchmarkWriteVarStr4(b *testing.B) { } // BenchmarkWriteVarStr10 performs a benchmark on how long it takes to write a -// four byte variable length string. +// ten byte variable length string. func BenchmarkWriteVarStr10(b *testing.B) { for i := 0; i < b.N; i++ { btcwire.TstWriteVarString(ioutil.Discard, 0, "test012345") } } +// BenchmarkReadOutPoint performs a benchmark on how long it takes to read a +// transaction output point. +func BenchmarkReadOutPoint(b *testing.B) { + buf := []byte{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Previous output hash + 0xff, 0xff, 0xff, 0xff, // Previous output index + } + var op btcwire.OutPoint + for i := 0; i < b.N; i++ { + btcwire.TstReadOutPoint(bytes.NewBuffer(buf), 0, 0, &op) + } +} + // BenchmarkWriteOutPoint performs a benchmark on how long it takes to write a // transaction output point. func BenchmarkWriteOutPoint(b *testing.B) { diff --git a/internal_test.go b/internal_test.go index a49e376f..bae8181e 100644 --- a/internal_test.go +++ b/internal_test.go @@ -103,6 +103,12 @@ func TstReadMessageHeader(r io.Reader) (*messageHeader, error) { return readMessageHeader(r) } +// TstReadOutPoint makes the internal readOutPoint function available to the +// test package. +func TstReadOutPoint(r io.Reader, pver uint32, version uint32, op *OutPoint) error { + return readOutPoint(r, pver, version, op) +} + // TstWriteOutPoint makes the internal writeOutPoint function available to the // test package. func TstWriteOutPoint(w io.Writer, pver uint32, version uint32, op *OutPoint) error {