Skip to content

Commit

Permalink
fix debug page and expose memory heap data
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jun 21, 2024
1 parent 0faef06 commit a597ba1
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions debug/debug.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@

var geojsonvt = require('../src/index.js');
import geojsonvt from '../src/index.js';
import {getHeapStatistics} from 'v8';
import {readFileSync} from 'fs';

console.time('load data');
var data = require('./data/hrr.json');
const data = JSON.parse(readFileSync(new URL('data/hrr.json', import.meta.url)));
console.timeEnd('load data');

var tileIndex = geojsonvt(data, {
global.gc();
const size = getHeapStatistics().used_heap_size;

const tileIndex = geojsonvt(data, {
debug: 1
});

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

console.time('drill down');
for (var i = 0; i < 10; i++) {
for (var j = 0; j < 10; j++) {
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
tileIndex.getTile(7, 30 + i, 45 + j);
}
}
for (var i = 0; i < 10; i++) {
for (var j = 0; j < 10; j++) {
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
tileIndex.getTile(8, 60 + i, 90 + j);
}
}
for (var i = 0; i < 10; i++) {
for (var j = 0; j < 10; j++) {
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
tileIndex.getTile(10, 240 + i, 360 + j);
}
}
console.timeEnd('drill down');

console.log('tiles generated:', tileIndex.total, JSON.stringify(tileIndex.stats));

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

// tileIndex.maxZoom = 14;
// tileIndex.getTile(14, 4100, 6200);
Expand Down

0 comments on commit a597ba1

Please sign in to comment.