mirror of https://github.com/go-redis/redis.git
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
|
package redis_test
|
||
|
|
||
|
import (
|
||
|
"github.com/vmihailenco/bufreader"
|
||
|
. "launchpad.net/gocheck"
|
||
|
|
||
|
"github.com/vmihailenco/redis"
|
||
|
)
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
|
||
|
type RequestTest struct{}
|
||
|
|
||
|
var _ = Suite(&RequestTest{})
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
|
||
|
func (t *RequestTest) SetUpTest(c *C) {}
|
||
|
|
||
|
func (t *RequestTest) TearDownTest(c *C) {}
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
|
||
|
func (t *RequestTest) BenchmarkStatusReq(c *C) {
|
||
|
c.StopTimer()
|
||
|
|
||
|
rd := bufreader.NewSizedReader(1024)
|
||
|
rd.Set([]byte("+OK\r\n"))
|
||
|
req := redis.NewStatusReq()
|
||
|
|
||
|
for i := 0; i < 10; i++ {
|
||
|
rd.ResetPos()
|
||
|
vI, err := req.ParseReply(rd)
|
||
|
c.Check(err, IsNil)
|
||
|
c.Check(vI, Equals, "OK")
|
||
|
|
||
|
req.SetVal(vI)
|
||
|
v, err := req.Reply()
|
||
|
c.Check(err, IsNil)
|
||
|
c.Check(v, Equals, "OK")
|
||
|
}
|
||
|
|
||
|
c.StartTimer()
|
||
|
|
||
|
for i := 0; i < c.N; i++ {
|
||
|
rd.ResetPos()
|
||
|
v, _ := req.ParseReply(rd)
|
||
|
req.SetVal(v)
|
||
|
req.Reply()
|
||
|
}
|
||
|
}
|