2012-02-07 05:34:04 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
/*
|
|
|
|
* Time logging with/without a try/catch-guard on the JSON.stringify.
|
|
|
|
*/
|
|
|
|
|
2012-02-10 08:14:33 +00:00
|
|
|
console.log('Time try/catch-guard on JSON.stringify:');
|
2012-02-07 05:34:04 +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-07 05:34:04 +00:00
|
|
|
//records.push(s);
|
|
|
|
}
|
|
|
|
var collector = new Collector();
|
|
|
|
|
|
|
|
var log = new Logger({
|
2012-02-10 08:14:33 +00:00
|
|
|
name: 'timeguard',
|
2012-02-07 05:34:04 +00:00
|
|
|
src: true,
|
|
|
|
stream: collector
|
|
|
|
});
|
|
|
|
|
|
|
|
var ms = ben(1e5, function () {
|
2012-02-10 08:14:33 +00:00
|
|
|
log.info('hi');
|
2012-02-07 05:34:04 +00:00
|
|
|
});
|
|
|
|
console.log(' - log.info: %dms per iteration', ms);
|