KirkMcDonald / kirkmcdonald.github.io

Simple web-based calculator for the game Factorio.
Apache License 2.0
553 stars 147 forks source link

Improve performance with many items #143

Open Illiou opened 5 years ago

Illiou commented 5 years ago

Currently the more items you add the worse performance gets. After around 10 items it becomes noticeable, after 20 it makes the page unusable as after every click you have to wait multiple seconds for the page to become responsive again while the CPU is running at full load.

Crunching a few numbers should probably not take that long. It should also probably not increase every time you add even the same item again since in that scenario the number of calculated items should stay roughly the same.

I feel like there is likely some calculation which is redone again for every item which could instead be done once in the end, or some similar easy performance fix. (I was also wondering if the graph in the Visualize tab is recalculated every time something is changed or only when the tab is opened, which could of course have a big impact)

And if there is no easy performance fix to be found an option to recalculate everything only once you press a button would be much appreciated. This would make it possible to enter bigger setups without lag and then calculate it once in the end.

Thank you.

magneticflux- commented 3 years ago

I'm using Firefox 92.0.1 and it seems to do this huge calculation every time I finish scrolling, which causes extreme lag when viewing large recipes that require scrolling down.

Seems like it could be fixed by this: https://github.com/popperjs/popper-core/issues/624#issuecomment-395515433 (Which was incorporated into Popper docs here: https://popper.js.org/docs/v2/tutorial/#performance (That's for v2 though, so some minor migrations need to be done: https://popper.js.org/docs/v2/migration-guide/))