Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save springmeyer/5577a509234218fd0e2f to your computer and use it in GitHub Desktop.
Save springmeyer/5577a509234218fd0e2f to your computer and use it in GitHub Desktop.
tilelive-overlay benchmark

Setup

npm install

Running

node bench.js 10 100

mapnik 2.3.x @94e78f2ae4

iterations: 100
concurrency: 10
max mem: 93.75mb/98304000
max heap: 10.11mb
total time: 4519ms
--------------------

mapnik master @b2d62d5fd9

$ node bench.js 10 100
iterations: 100
concurrency: 10
max mem: 88.17mb/92450816
max heap: 10.17mb
total time: 2122ms
---------------------
var fs = require('fs');
var Overlay = require('tilelive-overlay');
var bytes = require('bytes');
var queue = require('queue-async');
var collect_memstats = true;
function render(stats,filename,callback) {
new Overlay('overlaydata://' + fs.readFileSync(filename, 'utf8'),
function(err, source) {
var q = queue(4);
for (var i = 0; i < 16; i++) q.defer(function(done) {
source.getTile(0,0,0, function(err,image) {
if (err) throw err;
done();
});
});
q.awaitAll(function() {
stats.count++;
if (collect_memstats) {
var mem = process.memoryUsage()
if (mem.rss > stats.max_rss) stats.max_rss = mem.rss
if (mem.heapUsed > stats.max_heap) stats.max_heap = mem.heapUsed
}
callback(null);
});
}
);
}
function test(concurrency,iterations) {
var stats = {
count:0,
max_rss:0,
max_heap:0
}
var q = queue(concurrency);
for (var i=0;i<iterations;i++) {
q.defer(render,stats,'./example.geojson');
}
console.time("total time");
q.awaitAll(function(error, results) {
if (error) throw error;
if (iterations != stats.count) {
throw new Error("did not fully finish " + iterations + " " + stats.count);
}
console.log("iterations: " + iterations)
console.log("concurrency: " + concurrency)
if (collect_memstats) {
console.log("max mem: " + bytes(stats.max_rss) + '/' + stats.max_rss);
console.log("max heap: " + bytes(stats.max_heap));
}
console.timeEnd("total time");
console.log('---------------------')
});
};
if (!process.argv[2]) {
console.log('please pass concurrency as first arg');
process.exit(-1)
}
if (!process.argv[3]) {
console.log('please pass iterations as second arg');
process.exit(-1)
}
test(+process.argv[2],+process.argv[3])
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"name" : "bench",
"main" : "./bench.js",
"dependencies" : {
"tilelive-overlay":"https://github.com/mapbox/tilelive-overlay/tarball/bench-async",
"queue-async":"*",
"bytes":"*"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment