tweaks to this timing tool when looking at #182

This commit is contained in:
Trent Mick 2014-11-17 22:49:38 -08:00
parent 79fc7178bd
commit b284480e5e

View file

@ -6,23 +6,21 @@
console.log('Time try/catch-guard on JSON.stringify:'); console.log('Time try/catch-guard on JSON.stringify:');
var ben = require('ben'); // npm install ben var ben = require('ben'); // npm install ben
var Logger = require('../lib/bunyan'); var bunyan = require('../lib/bunyan');
var records = []; function Collector() {}
function Collector() { Collector.prototype.write = function (s) {};
}
Collector.prototype.write = function (s) {
//records.push(s);
}
var collector = new Collector();
var log = new Logger({ var log = bunyan.createLogger({
name: 'timeguard', name: 'timeguard',
src: true, stream: new Collector()
stream: collector
}); });
var ms = ben(1e5, function () { var ms = ben(1e5, function () {
log.info('hi'); log.info('hi');
}); });
console.log(' - log.info: %dms per iteration', ms); console.log(' - log.info: %dms per iteration', ms);
console.log('\nNow you need to manually change `Logger.prototype._emit` in\n'
+ '"../lib/bunyan.js" to (not) have a try/catch around `JSON.stringify`.\n'
+ 'Then re-run this a few times to compare speed.');