forked from trentm/node-bunyan
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trentm#401 MkLogEmitter Closure Significantly Hampers Performance
- Loading branch information
Showing
4 changed files
with
121 additions
and
78 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env node | ||
/* | ||
* Time logging below the current level, which should do very little work. | ||
*/ | ||
|
||
console.log('Time log.trace() when log level is "info":'); | ||
|
||
var ben = require('ben'); // npm install ben | ||
var bunyan = require('../lib/bunyan'); | ||
|
||
function Collector() {} | ||
Collector.prototype.write = function (s) {}; | ||
|
||
var log = bunyan.createLogger({ | ||
name: 'timeguard', | ||
level: 'info', | ||
stream: new Collector() | ||
}); | ||
|
||
var i = 0; | ||
var ms, fields; | ||
|
||
ms = ben(1e7, function () { | ||
log.trace({ count: i++ }, 'hello'); | ||
}); | ||
console.log(' - log.trace: %dms per iteration', ms); |