Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 516 Bytes

File metadata and controls

23 lines (15 loc) · 516 Bytes

Reading each byte of a buffer

Each byte (bg) can be read using:

  • _, _ = bb.Read(bg)
  • bg, _ = bb.ReadByte()

When treating every byte, ReadByte provides 20%+ improvement. One less variable is part of the explanation.

src>go test -bench=. ./readbyte

Results

go version go1.12.6 windows/amd64

pkg: github.com/iWdGo/GoCompilerEfficiency/src/readbyte
BenchmarkBufferRead-4             200000              8540 ns/op
BenchmarkRBufferReadByte-4        200000              5971 ns/op
PASS