Created
June 7, 2017 17:16
-
-
Save mcollina/d6439613652fe8b199c71dd11313499d to your computer and use it in GitHub Desktop.
pino-multistream-benchmark
This file contains hidden or 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
'use strict' | |
var bench = require('fastbench') | |
var bunyan = require('bunyan') | |
var pinoms = require('./index') | |
var fs = require('fs') | |
var dest = fs.createWriteStream('/dev/null') | |
var pino = require('pino') | |
var tenStreams = [ | |
{stream: dest}, | |
{stream: dest}, | |
{stream: dest}, | |
{stream: dest}, | |
{stream: dest}, | |
{level: 'debug', stream: dest}, | |
{level: 'debug', stream: dest}, | |
{level: 'trace', stream: dest}, | |
{level: 'warn', stream: dest}, | |
{level: 'fatal', stream: dest} | |
] | |
var pinomsTen = pinoms({streams: tenStreams}) | |
var fourStreams = [ | |
{stream: dest}, | |
{stream: dest}, | |
{level: 'debug', stream: dest}, | |
{level: 'trace', stream: dest} | |
] | |
var pinomsFour = pinoms({streams: fourStreams}) | |
var pinomsOne = pinoms({streams: [{stream: dest}]}) | |
var blogOne = bunyan.createLogger({ | |
name: 'myapp', | |
streams: [{stream: dest}] | |
}) | |
var blogTen = bunyan.createLogger({ | |
name: 'myapp', | |
streams: tenStreams | |
}) | |
var blogFour = bunyan.createLogger({ | |
name: 'myapp', | |
streams: fourStreams | |
}) | |
var pinoNewTen = pino({ | |
level: 'info' | |
}, pino.multistream()) | |
for (var i = 0; i < 10; i++) { | |
pinoNewTen.stream.add(30, dest) | |
} | |
var pinoNewFour = pino({ | |
level: 'info' | |
}, pino.multistream()) | |
for (var i = 0; i < 4; i++) { | |
pinoNewFour.stream.add(30, dest) | |
} | |
var pinoNewOne = pino({ | |
level: 'info' | |
}, pino.multistream()) | |
pinoNewOne.stream.add(30, dest) | |
var max = 10 | |
var run = bench([ | |
function benchBunyanTen (cb) { | |
for (var i = 0; i < max; i++) { | |
blogTen.info('hello world') | |
blogTen.debug('hello world') | |
blogTen.trace('hello world') | |
blogTen.warn('hello world') | |
blogTen.fatal('hello world') | |
} | |
setImmediate(cb) | |
}, | |
function benchPinoMSTen (cb) { | |
for (var i = 0; i < max; i++) { | |
pinomsTen.info('hello world') | |
pinomsTen.debug('hello world') | |
pinomsTen.trace('hello world') | |
pinomsTen.warn('hello world') | |
pinomsTen.fatal('hello world') | |
} | |
setImmediate(cb) | |
}, | |
function benchPinoNewTen (cb) { | |
for (var i = 0; i < max; i++) { | |
pinoNewTen.info('hello world') | |
pinoNewTen.info('hello world') | |
pinoNewTen.info('hello world') | |
pinoNewTen.info('hello world') | |
pinoNewTen.info('hello world') | |
} | |
setImmediate(cb) | |
}, | |
function benchBunyanFour (cb) { | |
for (var i = 0; i < max; i++) { | |
blogFour.info('hello world') | |
blogFour.debug('hello world') | |
blogFour.trace('hello world') | |
} | |
setImmediate(cb) | |
}, | |
function benchPinoMSFour (cb) { | |
for (var i = 0; i < max; i++) { | |
pinomsFour.info('hello world') | |
pinomsFour.debug('hello world') | |
pinomsFour.trace('hello world') | |
} | |
setImmediate(cb) | |
}, | |
function benchPinoNewFour (cb) { | |
for (var i = 0; i < max; i++) { | |
pinoNewFour.info('hello world') | |
pinoNewFour.info('hello world') | |
pinoNewFour.info('hello world') | |
} | |
setImmediate(cb) | |
}, | |
function benchBunyanOne (cb) { | |
for (var i = 0; i < max; i++) { | |
blogOne.info('hello world') | |
} | |
setImmediate(cb) | |
}, | |
function benchPinoMSOne (cb) { | |
for (var i = 0; i < max; i++) { | |
pinomsOne.info('hello world') | |
} | |
setImmediate(cb) | |
}, | |
function benchPinoNewOne (cb) { | |
for (var i = 0; i < max; i++) { | |
pinoNewOne.info('hello world') | |
} | |
setImmediate(cb) | |
} | |
], 10000) | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment