Closed smallnest closed 5 years ago
when i bench this code, No improvement
func BenchmarkReader_ReadCommand(b *testing.B) {
var rd *Reader
buff := bytes.NewBufferString("")
rd = NewReader(buff)
s := "*3\r\n$3\r\nSET\r\n$1\r\n1\r\n$1\r\n1\r\n"
b.ResetTimer()
for i := 0; i < b.N; i++ {
buff.WriteString(s)
rd.ReadCommand()
}
}
$ go test -bench=. --benchmem . --run=BenchmarkParser_ReadCommand
goos: darwin
goarch: amd64
pkg: github.com/tidwall/redcon
BenchmarkReader_ReadCommand-4 5000000 348 ns/op 213 B/op 3 allocs/op
pkg: github.com/smallnest/redcon
BenchmarkReader_ReadCommand-4 3000000 584 ns/op 294 B/op 3 allocs/op
closed it since I had to use a customized redcon
I am using redcon.Reader to parse commands but redcon.Reader has not export the readCommands so I can't use it to read multiple commands in pipeline mode.
Could you export the ReadCommands method?