You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Float16Array lookups appear to be much less performant compared to Float32Array lookups #781
Hi,
I am using your library in hopes to cut down on memory consumption in my application. I have an array of floats with ~15 million entries, and I have found array lookups to be much slower since converting my Float32Array data type into a Float16Array.
I am trying to figure out if I am doing something incorrectly or if a performance hit is expected on lookups of an array of such a large size. Float16.js get() method is taking lots of time on my performance scans.
float_16_arr[i]; // much slower float_32_arr[i]; // much faster
It's logical. So sensitive to performance features like typed array magic is impossible to make so performant only in the userland as performant they can be done in engines internals. If you need them only for performance, it's better to avoid polyfills. However, they are fine for cases when performance is not so critical, you need them for something else like ToFloat16 conversion, backward compatibility, etc.
Unfortunately, Float16Array is not as fast in performance. Each time you get or write a value, it is converted by Proxy.
If you are concerned about performance, it is recommended to keep the data as a Uint16Array and use only getFloat16 and setFloat16 provided by this library.
Activity
zloirock commentedon Oct 10, 2022
It's logical. So sensitive to performance features like typed array magic is impossible to make so performant only in the userland as performant they can be done in engines internals. If you need them only for performance, it's better to avoid polyfills. However, they are fine for cases when performance is not so critical, you need them for something else like
ToFloat16conversion, backward compatibility, etc.petamoriken commentedon Oct 17, 2022
Unfortunately,
Float16Arrayis not as fast in performance. Each time you get or write a value, it is converted byProxy.If you are concerned about performance, it is recommended to keep the data as a
Uint16Arrayand use onlygetFloat16andsetFloat16provided by this library.petamoriken commentedon Feb 19, 2023
FYI: https://github.com/tc39/proposal-float16array