Add benchmarks for writeVarString.

This commit adds a couple of benchmarks for the writeVarString function.
This commit is contained in:
Dave Collins 2013-11-05 23:49:34 -06:00
parent 4002051a22
commit fa8f666e8c

View file

@ -96,3 +96,19 @@ func BenchmarkReadVarStr10(b *testing.B) {
btcwire.TstReadVarString(bytes.NewBuffer(buf), 0)
}
}
// BenchmarkWriteVarStr4 performs a benchmark on how long it takes to write a
// four byte variable length string.
func BenchmarkWriteVarStr4(b *testing.B) {
for i := 0; i < b.N; i++ {
btcwire.TstWriteVarString(ioutil.Discard, 0, "test")
}
}
// BenchmarkWriteVarStr10 performs a benchmark on how long it takes to write a
// four byte variable length string.
func BenchmarkWriteVarStr10(b *testing.B) {
for i := 0; i < b.N; i++ {
btcwire.TstWriteVarString(ioutil.Discard, 0, "test012345")
}
}