Add benchmarks for writeOutPoint.

This commit adds a benchmark for the writeOutPoint function.
This commit is contained in:
Dave Collins 2013-11-06 00:43:52 -06:00
parent 8a1828a2d6
commit 547b648702
2 changed files with 18 additions and 0 deletions

View file

@ -112,3 +112,15 @@ func BenchmarkWriteVarStr10(b *testing.B) {
btcwire.TstWriteVarString(ioutil.Discard, 0, "test012345") btcwire.TstWriteVarString(ioutil.Discard, 0, "test012345")
} }
} }
// BenchmarkWriteOutPoint performs a benchmark on how long it takes to write a
// transaction output point.
func BenchmarkWriteOutPoint(b *testing.B) {
op := &btcwire.OutPoint{
Hash: btcwire.ShaHash{},
Index: 0,
}
for i := 0; i < b.N; i++ {
btcwire.TstWriteOutPoint(ioutil.Discard, 0, 0, op)
}
}

View file

@ -102,3 +102,9 @@ func TstWriteBlockHeader(w io.Writer, pver uint32, bh *BlockHeader) error {
func TstReadMessageHeader(r io.Reader) (*messageHeader, error) { func TstReadMessageHeader(r io.Reader) (*messageHeader, error) {
return readMessageHeader(r) return readMessageHeader(r)
} }
// TstWriteOutPoint makes the internal writeOutPoint function available to the
// test package.
func TstWriteOutPoint(w io.Writer, pver uint32, version uint32, op *OutPoint) error {
return writeOutPoint(w, pver, version, op)
}