rii-mango / Daikon

A JavaScript DICOM reader.
Other
221 stars 54 forks source link

Slow memory allocation and fragmentation occurs in `getInterpolatedData()` #16

Closed DLiblik closed 6 years ago

DLiblik commented 6 years ago

getInterpolatedData() allocates its output array one index at a time, resulting in fragmentation and slow performance. This can be fixed by pre-allocating the output array. I did this in PR #11

DLiblik commented 6 years ago

For more evidence of how much faster pre-declaring the array size is, please see:

https://jsperf.com/preallocating-array/8

rii-mango commented 6 years ago

Nice, fixed. Thanks for your great additions.