node-bunyan-lite/tools/timesrc.js

38 lines
821 B
JavaScript
Raw Normal View History

#!/usr/bin/env node
/*
* Time 'src' fields (getting log call source info). This is expensive.
*/
2012-02-10 08:14:33 +00:00
console.log('Time adding "src" field with call source info:');
var ben = require('ben'); // npm install ben
var Logger = require('../lib/bunyan');
var records = [];
function Collector() {
}
2012-02-10 08:14:33 +00:00
Collector.prototype.write = function (s) {
2013-03-29 00:42:32 +00:00
//records.push(s);
}
var collector = new Collector();
var logwith = new Logger({
2013-03-29 00:42:32 +00:00
name: 'with-src',
src: true,
stream: collector
});
var ms = ben(1e5, function () {
2013-03-29 00:42:32 +00:00
logwith.info('hi');
});
console.log(' - log.info with src: %dms per iteration', ms);
var logwithout = new Logger({
2013-03-29 00:42:32 +00:00
name: 'without-src',
stream: collector
});
var ms = ben(1e5, function () {
2013-03-29 00:42:32 +00:00
logwithout.info('hi');
});
console.log(' - log.info without src: %dms per iteration', ms);