-
Notifications
You must be signed in to change notification settings - Fork 7
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
Buffer.(read|write)(U)Int(LE|BE)(8|16|32) #2
Comments
|
I was thinking maybe something like this could be faster:
|
Deno is doing this: denoland/deno#17815 |
Word of warning from the author of the linked Deno PR: The performance benefit is nothing that spectacular. I'm not sure how the Node.js Buffer method implementations are written, but the Deno std/node Buffer polyfills were written with basically byte-by-byte reading/writing into the When I tried out the speed of reading or writing into an ArrayBuffer through a plain DataView, it was 2-3 times faster than the Buffer polyfills. Unfortunately, when I tried to do the same using a "hidden" DataView like is proposed here with the My guess is that V8 is somehow "gatekeeping" some optimisations behind a precondition that is not fulfilled by the "hidden" DataView. Though, my tests were done with not the original code itself but an imitation that used the EDIT: Here's some numbers from my branch:
All of these are working with an 8 byte buffer, the 4 on the top is the Deno Buffer polyfill and bottom ones are as named the plain DataView. Both eventually go through the same |
Update: Starting in V8 12.0 it seems that we'll see improved performance for |
Just adding something that I've been looking at which could maybe be improved.
Using Node Buffer vs Int32Array to read/write 32 bit values to buffers.
The text was updated successfully, but these errors were encountered: