h3Perfs = {
let durations = [];
const stepSize = 50000;
const maxSize = randomPoints.length;
for (let i = stepSize; i <= maxSize; i += stepSize) {
const currentSlice = randomPoints.slice(0, i);
const start = performance.now();
const parentResolution = 5;
const groupedFeatures = {};
currentSlice.forEach((feature) => {
const h3Index = feature.properties.h3Index;
const parentIndex = h3.cellToParent(h3Index, parentResolution);
if (!groupedFeatures[parentIndex]) {
groupedFeatures[parentIndex] = [];
}
groupedFeatures[parentIndex].push(feature);
});
const end = performance.now();
const duration = end - start;
durations.push({ size: i, duration: duration });
console.log(
`Size: ${i}, Clusters: ${
Object.keys(groupedFeatures).length
}, Duration: ${duration}ms`
);
}
return durations;
}