From 901c439dfe4a1c2f483c70ec0d703cc8219c9680 Mon Sep 17 00:00:00 2001 From: Dave Grijalva Date: Sat, 11 Apr 2015 13:31:06 -0700 Subject: [PATCH] added benchmark for hmac signing --- hmac_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hmac_test.go b/hmac_test.go index 3cd4203..aaa98be 100644 --- a/hmac_test.go +++ b/hmac_test.go @@ -77,3 +77,26 @@ func TestHMACSign(t *testing.T) { } } } + +func BenchmarkHMACSigning(b *testing.B) { + + var preppedData = make([]struct { + t *jwt.Token + method jwt.SigningMethod + k interface{} + }, len(hmacTestData)) + + for i, data := range hmacTestData { + preppedData[i].t, _ = jwt.Parse(data.tokenString, func(*jwt.Token) (interface{}, error) { return nil, nil }) + preppedData[i].method = jwt.GetSigningMethod(data.alg) + } + + for _, data := range preppedData { + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + data.t.SignedString(hmacTestKey) + } + }) + } + +}