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

Stop using Node.js Buffer #84

Open
Lorp opened this issue May 22, 2023 · 1 comment
Open

Stop using Node.js Buffer #84

Lorp opened this issue May 22, 2023 · 1 comment

Comments

@Lorp
Copy link
Owner

Lorp commented May 22, 2023

Using Buffer in Node.js is inefficient compared with DataView and ArrayBuffer (which are available everywhere). Much better to subclass DataView and at the same time handle pointer increments within the class.

@Lorp
Copy link
Owner Author

Lorp commented May 22, 2023

Test on writing uint32 values into 100000000 bytes. Timings after warmup:

DataView: 35.777ms
DataView subclass: 39.698ms
Buffer: 182.879ms

So by moving to DataView subclass we sacrifice 10% speed, but gain significantly in code clarity and error avoidance.

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

No branches or pull requests

1 participant