-
Notifications
You must be signed in to change notification settings - Fork 29
Description
We extend the mjs
npm module to add quite a bit of additional utility functions. Similar to mjs, we often (but not always) follow the signature where a third parameter can be passed for the output variable. In tight loops, this avoids allocating an array in each invocation.
However, the code often defaults to allocating a Float32Array
which is often not type-compliant with our usual vectors (i.e., JS arrays with a fixed size).
I also benchmarked the different options a bit and found out that the Float32Array
doesn't really add much benefit. In contrast, if the third parameter is NOT used, allocating a Float32Array is even worse than allocating a normal vector.
Benchmark is here:
On Chrome:
On Firefox, float32 has a slight benefit (but still not worth it imo):
Proposal:
We should clean up the mjs module so that float32 is only used where it really makes sense. maybe we can even get rid of the original mjs module and use something else?