Added benchmark

This commit is contained in:
Dimitrij Denissenko 2015-01-31 09:14:25 +00:00
parent 70c4c19f1d
commit fe4c2d4918
1 changed files with 21 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package redis_test
import (
"sync"
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@ -130,3 +131,23 @@ var _ = Describe("Pool", func() {
})
})
func BenchmarkPool(b *testing.B) {
client := redis.NewClient(&redis.Options{
Addr: redisAddr,
})
defer client.Close()
pool := client.Pool()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
conn, _, err := pool.Get()
if err != nil {
b.Fatalf("no error expected on pool.Get but received: %s", err.Error())
}
if err = pool.Put(conn); err != nil {
b.Fatalf("no error expected on pool.Put but received: %s", err.Error())
}
}
})
}