added benchmark for hmac signing

This commit is contained in:
Dave Grijalva 2015-04-11 13:31:06 -07:00
parent 3dd0a21a31
commit 901c439dfe
1 changed files with 23 additions and 0 deletions

View File

@ -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)
}
})
}
}