Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array methods (sort, forEach, map...) are slow on big Reactor arrays #42

Open
Sliverside opened this issue Nov 14, 2023 · 0 comments
Open

Comments

@Sliverside
Copy link

Hi,

First thank you for this library !

I was doing some test and i find-out that Reactor arrays new Reactor([]) are really slow when using the sort method myReactor.sort on big Reactor arrays. For an array of 1000 items it take me ~ 30ms and for 5000 items it take me ~6800ms and this his exponential.

The same problem happened with Array.forEach and Array.map but duration is linear.

A workaround is to use shuck, Array.splice and Array.length like that :

const reactorArray = new Reactor([])
const newArray = shuck(reactorArray).sort();
reactorArray.length = 0; // without this line, the problem stay the same
reactorArray.splice(0, 0, ...newArray);

i have done a CodePen (https://codepen.io/sliverside/pen/yLZoJWJ) where you can see/modify/adapt my tests.

Thanks for your time !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant