Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace JsonWebToken ReadPayloadValue with a delegate #2981

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

pmaytak
Copy link
Contributor

@pmaytak pmaytak commented Nov 5, 2024

@pmaytak pmaytak changed the title Replace JsonWebToken read overload method with delegates to read token values. Replace JsonWebToken ReadPayloadValue with a delegate Nov 6, 2024
@pmaytak
Copy link
Contributor Author

pmaytak commented Nov 7, 2024

Looks like when using delegates there're extra allocations because of:

string claimName = reader.GetString();
claims[claimName] = ReadTokenPayloadValueDelegate(ref reader, claimName);
Delegates Method Mean Ratio Error StdDev P90 P95 P100 Gen0 Allocated Alloc Ratio
Without JsonWebTokenHandler_ValidateTokenAsyncWithTVP 30.72 μs 1.000 0.026 μs 0.055 μs 30.79 μs 30.81 μs 30.89 μs 0.2441 7.23 KB 1.00
With JsonWebTokenHandler_ValidateTokenAsyncWithTVP 30.66 μs 0.998 0.124 μs 0.273 μs 30.96 μs 31.02 μs 31.10 μs 0.3052 7.55 KB 1.04
Delegates Method Mean Ratio Error StdDev P90 P95 P100 Gen0 Allocated Alloc Ratio
Without ReadJWS_FromMemory 8.373 μs 1.00 0.0331 μs 0.0727 μs 8.465 μs 8.499 μs 8.530 μs 0.2289 5.84 KB 1.00
With ReadJWS_FromMemory 8.201 μs 0.98 0.0287 μs 0.0636 μs 8.295 μs 8.313 μs 8.357 μs 0.2441 6.07 KB 1.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant