aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/binary/binary_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/binary/binary_test.go')
-rw-r--r--src/encoding/binary/binary_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/encoding/binary/binary_test.go b/src/encoding/binary/binary_test.go
index aeb4212ec2..5971e0966a 100644
--- a/src/encoding/binary/binary_test.go
+++ b/src/encoding/binary/binary_test.go
@@ -706,3 +706,27 @@ func BenchmarkWriteSlice1000Float32s(b *testing.B) {
}
b.StopTimer()
}
+
+func BenchmarkReadSlice1000Uint8s(b *testing.B) {
+ bsr := &byteSliceReader{}
+ slice := make([]uint8, 1000)
+ buf := make([]byte, len(slice))
+ b.SetBytes(int64(len(buf)))
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bsr.remain = buf
+ Read(bsr, BigEndian, slice)
+ }
+}
+
+func BenchmarkWriteSlice1000Uint8s(b *testing.B) {
+ slice := make([]uint8, 1000)
+ buf := new(bytes.Buffer)
+ var w io.Writer = buf
+ b.SetBytes(1000)
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ buf.Reset()
+ Write(w, BigEndian, slice)
+ }
+}