-
-
Save trentm/c3dae02ef249a3cb3ec34a845d34244a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
* Time logging with closure-avoiding changes discussed in #401. | |
*/ | |
console.log('Time with/without closures in mkLogEmitter'); | |
var ben = require('ben'); // npm install ben | |
var bunyan = require('../lib/bunyan'); | |
function Collector() {} | |
Collector.prototype.write = function (s) {}; | |
var log = bunyan.createLogger({ | |
name: 'timeclosures', | |
stream: new Collector(), | |
level: 'info' | |
}); | |
var i, ms, fields; | |
i = 0; | |
ms = ben(1e7, function () { | |
i++; | |
log.trace({ count: i }, 'hello'); | |
}); | |
console.log(' - log.trace: %dms per iteration', ms); | |
console.log('\nNow you need to manually apply the patch for #401 and compare.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment