func newConnFunc(dial func() (net.Conn, error)) func() (*conn, error) { return func() (*conn, error) { netcn, err := dial() if err != nil { return nil, err } cn := &conn{ netcn: netcn, buf: make([]byte, 0, 64), } cn.rd = bufio.NewReader(cn) return cn, nil } }
func benchmarkParseReply(b *testing.B, reply string, p multiBulkParser, wanterr bool) { b.StopTimer() buf := &bufio.Buffer{} rd := bufio.NewReader(buf) for i := 0; i < b.N; i++ { buf.WriteString(reply) } b.StartTimer() for i := 0; i < b.N; i++ { _, err := parseReply(rd, p) if !wanterr && err != nil { panic(err) } } }