-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
61 lines (55 loc) · 1.58 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var Benchmark = require('benchmark');
var logops = require('../');
var bunyan = require('bunyan');
var logopsLogger;
function setupLogops() {
logops.getContext = function() {
return {
name: 'myapp',
hostname: 'jmendiaraMac.hi.inet',
pid: 12321
};
};
logops.format = logops.formatters.json;
logops.setLevel('info');
logopsLogger = logops;
}
var bunyanLogger;
function setupBunyan() {
bunyanLogger = bunyan.createLogger({
name: 'myapp'
});
bunyanLogger.level('info')
}
setupLogops();
setupBunyan();
new Benchmark.Suite('Basic logging')
.add('logops', function() {
logopsLogger.info({custom: 'field'}, 'This is a String');
})
.add('bunyan', function() {
bunyanLogger.info({custom: 'field'}, 'This is a String');
})
// add listeners
.on('cycle', function(event) {
process.stderr.write(String(event.target) + '\n');
})
.on('complete', function() {
process.stderr.write(this.name + ': Fastest is ' + this.filter('fastest').map('name') + '\n');
})
.run({ 'async': false });
new Benchmark.Suite('Disabled logging')
.add('logops', function() {
logopsLogger.debug({custom: 'field'}, 'This is a String');
})
.add('bunyan', function() {
bunyanLogger.debug({custom: 'field'}, 'This is a String');
})
// add listeners
.on('cycle', function(event) {
process.stderr.write(String(event.target) + '\n');
})
.on('complete', function() {
process.stderr.write(this.name + ': Fastest is ' + this.filter('fastest').map('name') + '\n');
})
.run({ 'async': false });