2012-02-06 04:33:57 +00:00
|
|
|
#!/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:');
|
2012-02-06 04:33:57 +00:00
|
|
|
|
|
|
|
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) {
|
2012-02-06 04:33:57 +00:00
|
|
|
//records.push(s);
|
|
|
|
}
|
|
|
|
var collector = new Collector();
|
|
|
|
|
|
|
|
var logwith = new Logger({
|
2012-02-10 08:14:33 +00:00
|
|
|
name: 'with-src',
|
2012-02-06 04:33:57 +00:00
|
|
|
src: true,
|
|
|
|
stream: collector
|
|
|
|
});
|
|
|
|
|
|
|
|
var ms = ben(1e5, function () {
|
2012-02-10 08:14:33 +00:00
|
|
|
logwith.info('hi');
|
2012-02-06 04:33:57 +00:00
|
|
|
});
|
|
|
|
console.log(' - log.info with src: %dms per iteration', ms);
|
|
|
|
|
|
|
|
var logwithout = new Logger({
|
2012-02-10 08:14:33 +00:00
|
|
|
name: 'without-src',
|
2012-02-06 04:33:57 +00:00
|
|
|
stream: collector
|
|
|
|
});
|
|
|
|
var ms = ben(1e5, function () {
|
2012-02-10 08:14:33 +00:00
|
|
|
logwithout.info('hi');
|
2012-02-06 04:33:57 +00:00
|
|
|
});
|
|
|
|
console.log(' - log.info without src: %dms per iteration', ms);
|