Skip to content

Instantly share code, notes, and snippets.

@trentm
Created October 7, 2016 20:59
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 trentm/c3dae02ef249a3cb3ec34a845d34244a to your computer and use it in GitHub Desktop.
Save trentm/c3dae02ef249a3cb3ec34a845d34244a to your computer and use it in GitHub Desktop.
#!/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