samsa
samsa copied to clipboard
Stop using Node.js Buffer
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.
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.