diff options
| author | Shulhan <m.shulhan@gmail.com> | 2018-10-20 00:27:54 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2024-01-25 04:01:14 +0700 |
| commit | 54386c4a7e68ab281545116220600f670e8f9e14 (patch) | |
| tree | 050e0a097f13f7a766f4d493e590cc57c9c10069 /src/encoding | |
| parent | f27c66c1f18522a75ddad61913176da3b24ed08c (diff) | |
| download | go-54386c4a7e68ab281545116220600f670e8f9e14.tar.xz | |
encoding/binary: add benchmark for writing slice of uint8
Diffstat (limited to 'src/encoding')
| -rw-r--r-- | src/encoding/binary/binary_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/encoding/binary/binary_test.go b/src/encoding/binary/binary_test.go index 4b22b28843..5fa9beda6d 100644 --- a/src/encoding/binary/binary_test.go +++ b/src/encoding/binary/binary_test.go @@ -697,6 +697,19 @@ func BenchmarkWriteSlice1000Int32s(b *testing.B) { b.StopTimer() } +func BenchmarkWriteSlice1024Uint8(b *testing.B) { + slice := make([]byte, 1024) + buf := new(bytes.Buffer) + buf.Grow(1024) + var w io.Writer = buf + b.SetBytes(1024) + b.ResetTimer() + for i := 0; i < b.N; i++ { + buf.Reset() + Write(w, BigEndian, slice) + } +} + func BenchmarkPutUint16(b *testing.B) { b.SetBytes(2) for i := 0; i < b.N; i++ { |
