1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-06 01:35:48 +03:00

Get rid of custom bufio package.

This commit is contained in:
Vladimir Mihailenco
2015-09-03 17:55:31 +03:00
parent dace69da84
commit 58cb170ac0
11 changed files with 107 additions and 150 deletions

View File

@@ -1,9 +1,9 @@
package redis
import (
"bufio"
"bytes"
"testing"
"gopkg.in/bufio.v1"
)
func BenchmarkParseReplyStatus(b *testing.B) {
@@ -27,20 +27,21 @@ func BenchmarkParseReplySlice(b *testing.B) {
}
func benchmarkParseReply(b *testing.B, reply string, p multiBulkParser, wanterr bool) {
b.StopTimer()
buf := &bufio.Buffer{}
rd := bufio.NewReader(buf)
buf := &bytes.Buffer{}
for i := 0; i < b.N; i++ {
buf.WriteString(reply)
}
cn := &conn{
rd: bufio.NewReader(buf),
buf: make([]byte, 0, defaultBufSize),
}
b.StartTimer()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := parseReply(rd, p)
_, err := parseReply(cn, p)
if !wanterr && err != nil {
panic(err)
b.Fatal(err)
}
}
}