MCPcopy
hub / github.com/golang-jwt/jwt / BenchmarkParseUnverified

Function BenchmarkParseUnverified

parser_test.go:836–861  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

834}
835
836func BenchmarkParseUnverified(b *testing.B) {
837 // Iterate over test data set and run tests
838 for _, data := range jwtTestData {
839 // If the token string is blank, use helper function to generate string
840 if data.tokenString == "" {
841 data.tokenString = signToken(data.claims, data.signingMethod)
842 }
843
844 // Parse the token
845 var parser = data.parser
846 if parser == nil {
847 parser = new(jwt.Parser)
848 }
849 // Figure out correct claims type
850 switch data.claims.(type) {
851 case jwt.MapClaims:
852 b.Run("map_claims", func(b *testing.B) {
853 benchmarkParsing(b, parser, data.tokenString, jwt.MapClaims{})
854 })
855 case *jwt.RegisteredClaims:
856 b.Run("registered_claims", func(b *testing.B) {
857 benchmarkParsing(b, parser, data.tokenString, &jwt.RegisteredClaims{})
858 })
859 }
860 }
861}
862
863// Helper method for benchmarking various parsing methods
864func benchmarkParsing(b *testing.B, parser *jwt.Parser, tokenString string, claims jwt.Claims) {

Callers

nothing calls this directly

Calls 2

benchmarkParsingFunction · 0.85
signTokenFunction · 0.70

Tested by

no test coverage detected