NREL / floorspace.js

Other
66 stars 35 forks source link

Performance updates #392

Closed benfen closed 2 years ago

benfen commented 3 years ago

Garden basket of performance tweaks along with a crude suite of performance tests. Primarily, the modifications to code focused on batching up related operations to reduce toil from repeatedly invoking the same code paths.

As part of the changes, I also updated the unit tests to use chrome to run instead of phantom and upgraded karma. This allowed me to setup the performance tests which can be run with npm run perf. For now, the reporting is sent to the perf.log file in test/perf/output and is minimal, but can readily be expanded in the future. The primary purpose of that suite for now is to attempt to quantize how effective the modifications have been. At this point, it would be advisable to take the results from the tests with a healthy dose of salt.

Outdated performance information

I'm leaving this in here for historical reasons, but there are some standing issues with the perf tests that currently precludes getting accurate information. Some pretty informal results from the performance tests: | Test | Average Time (without changes) | Average Time (with changes) | |-|-|-| | Moving/Zooming Grid (Small Plan) | 154.9ms | 187.4ms | | Moving/Zooming Grid (Large Plan) | 1741.6ms | 1063.4ms | | Moving/Zooming Grid (Large Plan 2) | 1156.1ms | 907.6ms | | Adding Spaces (Small Plan) | 47.9ms | 41.8ms | | Adding Spaces (Large Plan) | 6687ms | 2154.8ms |

~Based on this, adding additional spaces is far faster for big plans, although it should be faster for any floorplan. In general, panning the grid is faster, although there was some regression for small plans.~

At this point, adding new spaces and modifying existing spaces is ~5-7 times faster than it was before. The majority of these benefits came from removing lodash and refining a few of the array iterations to avoid as much busywork. I've cleared out a lot of the low-hanging fruit here - in other words, I think that further improvements will require more involved refactors of the general logical structure.

There are also some small improvements in terms of panning and zooming the grid, but these are not very noticeable to the user.

benfen commented 2 years ago

There's still a lot of stuff left to do and the perf tests could use some love, but things are stable for now and I'd like to get it merged in so it's not floating out here for too long.