From fe4c2d49184a61da32d8ce1f646d9b31ee888fd9 Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Sat, 31 Jan 2015 09:14:25 +0000 Subject: [PATCH] Added benchmark --- pool_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pool_test.go b/pool_test.go index f7916ec..051df1d 100644 --- a/pool_test.go +++ b/pool_test.go @@ -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()) + } + } + }) +}