Skip to content

Commit

Permalink
Massively improve performance by using flat arrays internally (Leafle…
Browse files Browse the repository at this point in the history
…t#223)

* use flat arrays for radically better performance

* improve memory for non-reduce instances

* cleanup
  • Loading branch information
mourner authored Apr 26, 2023
1 parent 11c4828 commit 17cb066
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 112 deletions.
7 changes: 6 additions & 1 deletion bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ for (let i = 0; i < 1000000; i++) {
global.gc();
const size = v8.getHeapStatistics().used_heap_size;

const index = new Supercluster({log: true, maxZoom: 6}).load(points);
const index = new Supercluster({
log: true,
maxZoom: 6,
// map: (props) => ({sum: props.index}),
// reduce: (accumulated, props) => { accumulated.sum += props.sum; }
}).load(points);

global.gc();
console.log(`memory used: ${ Math.round((v8.getHeapStatistics().used_heap_size - size) / 1024) } KB`);
Expand Down
Loading

0 comments on commit 17cb066

Please sign in to comment.