3 ms·
Just constructing a Uint32Array view of the buffer and accessing values by index way(!) faster than using the buffer.read* methods. Likewise, you don't need to
by zbjornson 8y ago
Just constructing a Uint32Array view of the buffer and accessing values by index way(!) faster than using the buffer.read* methods.
Likewise, you don't need to copy bytes in your last code sample. You can copy uint32s.
- mschuetz 8y agoThe buffer contains not just integer but also byte, unsigned byte, short, etc. Due to this, the buffer length may not be a multiple of 4, and Uint32Array views can only be constructed on buffers with a length of a multiple of 4. Edit: Also, the stride from one record to the next can be anything, e.g. 15. An Uint32Array would need a stride of 4 or a multiple of 4 to be useful. Edit2: I could try to create 4 Uint32Arrays with byteOffsets 0 to 3, and with a view length of a multiple of 4, then use the one that works with the attribute I'm currently processing. Not sure if that's really going to be faster but who knows.