From b284480e5eb7201bdeb4b64a28ff0ee168830e11 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 17 Nov 2014 22:49:38 -0800 Subject: [PATCH] tweaks to this timing tool when looking at #182 --- tools/timeguard.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tools/timeguard.js b/tools/timeguard.js index 93ba09c..7b6d1f9 100755 --- a/tools/timeguard.js +++ b/tools/timeguard.js @@ -6,23 +6,21 @@ console.log('Time try/catch-guard on JSON.stringify:'); var ben = require('ben'); // npm install ben -var Logger = require('../lib/bunyan'); +var bunyan = require('../lib/bunyan'); -var records = []; -function Collector() { -} -Collector.prototype.write = function (s) { - //records.push(s); -} -var collector = new Collector(); +function Collector() {} +Collector.prototype.write = function (s) {}; -var log = new Logger({ +var log = bunyan.createLogger({ name: 'timeguard', - src: true, - stream: collector + stream: new Collector() }); var ms = ben(1e5, function () { log.info('hi'); }); 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.');