-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Use lookup table for faster hex encoding #245
Conversation
Lookup table faster ~9-12 times than toString('hex') for each byte. See feross#219
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. An order of magnitude faster is a huge improvement. Nice work.
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.
Thanks for the PR, merged!
I asked on Twitter and someone suggested a tip that might further improve performance: https://twitter.com/WebReflection/status/1171871844141621249 if you're interested to try to improve it further :)
5.4.3 |
Oh, forget about |
@fanatid Of course, no problem. Thanks for your PR |
Lookup table faster ~9-12 times than toString('hex') for each byte. See #219
Benchmarks for generating lookup table:
code here
If we not allow V8 optimize function (because functions hot, they will be JIT-ed) fastest way:
Also this should be packed
smiarray what should give additional performance (not sure).Benchmarks for `toString('hex')` new-vs-old:
Code here
Current way slowly ~12 times. Tested 10k buffer with 1024 bytes: 995ms vs 79ms.