forked from mapbox/supercluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench.js
30 lines (24 loc) · 748 Bytes
/
bench.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Supercluster from './index.js';
import v8 from 'v8';
const points = [];
for (let i = 0; i < 1000000; i++) {
points.push({
type: 'Feature',
properties: {
index: i
},
geometry: {
type: 'Point',
coordinates: [
-180 + 360 * Math.random(),
-80 + 160 * Math.random()
]
}
});
}
global.gc();
const size = v8.getHeapStatistics().used_heap_size;
const index = new Supercluster({log: true, maxZoom: 6}).load(points);
global.gc();
console.log(`memory used: ${ Math.round((v8.getHeapStatistics().used_heap_size - size) / 1024) } KB`);
index.getClusters([-180, -90, 180, 90], 0).map(f => JSON.stringify(f.properties));