-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
⚡ middleware/pprof: improve performance #2709
Conversation
Concatenate the custom and fixed prefixes beforehand, so the trimmed path can be switched on against constant strings. goos: linux goarch: amd64 pkg: github.com/gofiber/fiber/v2/middleware/pprof cpu: 13th Gen Intel(R) Core(TM) i9-13900K BenchmarkPprof/Slow-32 4912642 246.3 ns/op 480 B/op 10 allocs/op BenchmarkPprof/Fast-32 411908472 2.913 ns/op 0 B/op 0 allocs/op PASS
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch
8f62457
to
7d644bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Description
Concatenate the custom and fixed prefixes beforehand, so the trimmed path can be switched on against constant strings.
Here's a simple benchmark:
To the maintainers: These slow patterns introduced by #2194 were quite obvious, and it would've been nice if they were called out when the PR was being reviewed. Thanks!
Type of change
Please delete options that are not relevant.
Checklist:
Commit formatting:
Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me/