Skip to content

Instantly share code, notes, and snippets.

@mapsam
Created May 12, 2016 23:22
Show Gist options
  • Save mapsam/071a0f66e434cfaa14ed85d276bf415b to your computer and use it in GitHub Desktop.
Save mapsam/071a0f66e434cfaa14ed85d276bf415b to your computer and use it in GitHub Desktop.
node-mapnik bencharmking for protozero
var mapnik = require('mapnik');
var fs = require('fs');
var iterations = 20000,
i = total = 0,
max = -Infinity,
min = Infinity,
tile = './785.vector.pbf';
decode();
function decode() {
var vt = new mapnik.VectorTile(14, 2749, 6335);
var buffer = fs.readFileSync(tile);
var start = new Date().getTime() / 1000;
vt.addData(buffer, function(err) {
if (err) throw err;
var finish = new Date().getTime() / 1000;
var duration = finish - start;
total += duration;
if (duration > max) max = duration;
if (duration < min) min = duration;
if (i <= iterations) {
i++;
decode();
} else {
console.log('Iterations : ' + iterations);
console.log('Total (s) : ' + total);
console.log('Average (s) : ' + total / iterations);
console.log('Max (s) : ' + max);
console.log('Min (s) : ' + min);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment