Projektstart
This commit is contained in:
95
backend/node_modules/pino/benchmarks/basic.bench.js
generated
vendored
Normal file
95
backend/node_modules/pino/benchmarks/basic.bench.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
const bunyan = require('bunyan')
|
||||
const bole = require('bole')('bench')
|
||||
const winston = require('winston')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const loglevel = require('./utils/wrap-log-level')(dest)
|
||||
const plogNodeStream = pino(dest)
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogMinLength = require('../')(pino.destination({ dest: '/dev/null', minLength: 4096 }))
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogDest = require('../')(pino.destination('/dev/null'))
|
||||
|
||||
process.env.DEBUG = 'dlog'
|
||||
const debug = require('debug')
|
||||
const dlog = debug('dlog')
|
||||
dlog.log = function (s) { dest.write(s) }
|
||||
|
||||
const max = 10
|
||||
const blog = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{
|
||||
level: 'trace',
|
||||
stream: dest
|
||||
}]
|
||||
})
|
||||
|
||||
require('bole').output({
|
||||
level: 'info',
|
||||
stream: dest
|
||||
}).setFastTime(true)
|
||||
|
||||
const chill = winston.createLogger({
|
||||
transports: [
|
||||
new winston.transports.Stream({
|
||||
stream: fs.createWriteStream('/dev/null')
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
const run = bench([
|
||||
function benchBunyan (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinston (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBole (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchDebug (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
dlog('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchLogLevel (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
loglevel.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPino (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLength (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStream (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
52
backend/node_modules/pino/benchmarks/child-child.bench.js
generated
vendored
Normal file
52
backend/node_modules/pino/benchmarks/child-child.bench.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
const bunyan = require('bunyan')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plogNodeStream = pino(dest).child({ a: 'property' }).child({ sub: 'child' })
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogDest = require('../')(pino.destination('/dev/null')).child({ a: 'property' }).child({ sub: 'child' })
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogMinLength = require('../')(pino.destination({ dest: '/dev/null', sync: false, minLength: 4096 }))
|
||||
.child({ a: 'property' })
|
||||
.child({ sub: 'child' })
|
||||
|
||||
const max = 10
|
||||
const blog = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{
|
||||
level: 'trace',
|
||||
stream: dest
|
||||
}]
|
||||
}).child({ a: 'property' }).child({ sub: 'child' })
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
73
backend/node_modules/pino/benchmarks/child-creation.bench.js
generated
vendored
Normal file
73
backend/node_modules/pino/benchmarks/child-creation.bench.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
const bunyan = require('bunyan')
|
||||
const bole = require('bole')('bench')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plogNodeStream = pino(dest)
|
||||
const plogDest = pino(pino.destination(('/dev/null')))
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogMinLength = require('../')(pino.destination({ dest: '/dev/null', sync: false, minLength: 4096 }))
|
||||
|
||||
const max = 10
|
||||
const blog = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{
|
||||
level: 'trace',
|
||||
stream: dest
|
||||
}]
|
||||
})
|
||||
|
||||
require('bole').output({
|
||||
level: 'info',
|
||||
stream: dest
|
||||
}).setFastTime(true)
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanCreation (cb) {
|
||||
const child = blog.child({ a: 'property' })
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleCreation (cb) {
|
||||
const child = bole('child')
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoCreation (cb) {
|
||||
const child = plogDest.child({ a: 'property' })
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthCreation (cb) {
|
||||
const child = plogMinLength.child({ a: 'property' })
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamCreation (cb) {
|
||||
const child = plogNodeStream.child({ a: 'property' })
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoCreationWithOption (cb) {
|
||||
const child = plogDest.child({ a: 'property' }, { redact: [] })
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
62
backend/node_modules/pino/benchmarks/child.bench.js
generated
vendored
Normal file
62
backend/node_modules/pino/benchmarks/child.bench.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
const bunyan = require('bunyan')
|
||||
const bole = require('bole')('bench')('child')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plogNodeStream = pino(dest).child({ a: 'property' })
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogDest = require('../')(pino.destination('/dev/null')).child({ a: 'property' })
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogMinLength = require('../')(pino.destination({ dest: '/dev/null', sync: false, minLength: 4096 }))
|
||||
|
||||
const max = 10
|
||||
const blog = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{
|
||||
level: 'trace',
|
||||
stream: dest
|
||||
}]
|
||||
}).child({ a: 'property' })
|
||||
|
||||
require('bole').output({
|
||||
level: 'info',
|
||||
stream: dest
|
||||
}).setFastTime(true)
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
88
backend/node_modules/pino/benchmarks/deep-object.bench.js
generated
vendored
Normal file
88
backend/node_modules/pino/benchmarks/deep-object.bench.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
const bunyan = require('bunyan')
|
||||
const bole = require('bole')('bench')
|
||||
const winston = require('winston')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plogNodeStream = pino(dest)
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogDest = require('../')(pino.destination('/dev/null'))
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogMinLength = require('../')(pino.destination({ dest: '/dev/null', sync: false, minLength: 4096 }))
|
||||
delete require.cache[require.resolve('../')]
|
||||
|
||||
const loglevel = require('./utils/wrap-log-level')(dest)
|
||||
|
||||
const deep = Object.assign({}, require('../package.json'), { level: 'info' })
|
||||
|
||||
const max = 10
|
||||
const blog = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{
|
||||
level: 'trace',
|
||||
stream: dest
|
||||
}]
|
||||
})
|
||||
|
||||
require('bole').output({
|
||||
level: 'info',
|
||||
stream: dest
|
||||
}).setFastTime(true)
|
||||
|
||||
const chill = winston.createLogger({
|
||||
transports: [
|
||||
new winston.transports.Stream({
|
||||
stream: fs.createWriteStream('/dev/null')
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchLogLevelDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
loglevel.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
50
backend/node_modules/pino/benchmarks/formatters.bench.js
generated
vendored
Normal file
50
backend/node_modules/pino/benchmarks/formatters.bench.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict'
|
||||
|
||||
const formatters = {
|
||||
level (label, number) {
|
||||
return {
|
||||
log: {
|
||||
level: label
|
||||
}
|
||||
}
|
||||
},
|
||||
bindings (bindings) {
|
||||
return {
|
||||
process: {
|
||||
pid: bindings.pid
|
||||
},
|
||||
host: {
|
||||
name: bindings.hostname
|
||||
}
|
||||
}
|
||||
},
|
||||
log (obj) {
|
||||
return { foo: 'bar', ...obj }
|
||||
}
|
||||
}
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
delete require.cache[require.resolve('../')]
|
||||
const pinoNoFormatters = require('../')(pino.destination('/dev/null'))
|
||||
delete require.cache[require.resolve('../')]
|
||||
const pinoFormatters = require('../')({ formatters }, pino.destination('/dev/null'))
|
||||
|
||||
const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchPinoNoFormatters (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
pinoNoFormatters.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoFormatters (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
pinoFormatters.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
67
backend/node_modules/pino/benchmarks/internal/custom-levels.js
generated
vendored
Normal file
67
backend/node_modules/pino/benchmarks/internal/custom-levels.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../../')
|
||||
|
||||
const base = pino(pino.destination('/dev/null'))
|
||||
const baseCl = pino({
|
||||
customLevels: { foo: 31 }
|
||||
}, pino.destination('/dev/null'))
|
||||
const child = base.child({})
|
||||
const childCl = base.child({
|
||||
customLevels: { foo: 31 }
|
||||
})
|
||||
const childOfBaseCl = baseCl.child({})
|
||||
|
||||
const max = 100
|
||||
|
||||
const run = bench([
|
||||
function benchPinoNoCustomLevel (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
base.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoCustomLevel (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
baseCl.foo({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchChildNoCustomLevel (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildCustomLevel (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
childCl.foo({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildInheritedCustomLevel (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
childOfBaseCl.foo({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildCreation (cb) {
|
||||
const child = base.child({})
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildCreationCustomLevel (cb) {
|
||||
const child = base.child({
|
||||
customLevels: { foo: 31 }
|
||||
})
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.foo({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
76
backend/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js
generated
vendored
Normal file
76
backend/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../../')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plog = pino(dest)
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogDest = require('../../')(pino.destination('/dev/null'))
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogAsync = require('../../')(pino.destination({ dest: '/dev/null', sync: false }))
|
||||
const deep = require('../../package.json')
|
||||
deep.deep = JSON.parse(JSON.stringify(deep))
|
||||
deep.deep.deep = JSON.parse(JSON.stringify(deep))
|
||||
const longStr = JSON.stringify(deep)
|
||||
|
||||
const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchPinoLongString (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestLongString (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncLongString (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncDeepObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info(deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 1000)
|
||||
|
||||
run(run)
|
||||
182
backend/node_modules/pino/benchmarks/internal/just-pino.bench.js
generated
vendored
Normal file
182
backend/node_modules/pino/benchmarks/internal/just-pino.bench.js
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../../')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plog = pino(dest)
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogDest = require('../../')(pino.destination('/dev/null'))
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogAsync = require('../../')(pino.destination({ dest: '/dev/null', sync: false }))
|
||||
const plogChild = plog.child({ a: 'property' })
|
||||
const plogDestChild = plogDest.child({ a: 'property' })
|
||||
const plogAsyncChild = plogAsync.child({ a: 'property' })
|
||||
const plogChildChild = plog.child({ a: 'property' }).child({ sub: 'child' })
|
||||
const plogDestChildChild = plogDest.child({ a: 'property' }).child({ sub: 'child' })
|
||||
const plogAsyncChildChild = plogAsync.child({ a: 'property' }).child({ sub: 'child' })
|
||||
|
||||
const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchPino (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDest (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoExtreme (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDestChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsyncChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDestChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsyncChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildCreation (cb) {
|
||||
const child = plog.child({ a: 'property' })
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestChildCreation (cb) {
|
||||
const child = plogDest.child({ a: 'property' })
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMulti (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestMulti (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncMulti (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoDestInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
75
backend/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js
generated
vendored
Normal file
75
backend/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../../')
|
||||
|
||||
const base = pino(pino.destination('/dev/null'))
|
||||
const child = base.child({})
|
||||
const childChild = child.child({})
|
||||
const childChildChild = childChild.child({})
|
||||
const childChildChildChild = childChildChild.child({})
|
||||
const child2 = base.child({})
|
||||
const baseSerializers = pino(pino.destination('/dev/null'))
|
||||
const baseSerializersChild = baseSerializers.child({})
|
||||
const baseSerializersChildSerializers = baseSerializers.child({})
|
||||
|
||||
const max = 100
|
||||
|
||||
const run = bench([
|
||||
function benchPinoBase (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
base.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
child.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
childChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
childChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChildChildChildChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
childChildChildChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoChild2 (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
child2.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoBaseSerializers (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
baseSerializers.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoBaseSerializersChild (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
baseSerializersChild.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoBaseSerializersChildSerializers (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
baseSerializersChildSerializers.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
86
backend/node_modules/pino/benchmarks/internal/redact.bench.js
generated
vendored
Normal file
86
backend/node_modules/pino/benchmarks/internal/redact.bench.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../../')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plog = pino(dest)
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogAsync = require('../../')(pino.destination({ dest: '/dev/null', sync: false }))
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogUnsafe = require('../../')({ safe: false }, dest)
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogUnsafeAsync = require('../../')(
|
||||
{ safe: false },
|
||||
pino.destination({ dest: '/dev/null', sync: false })
|
||||
)
|
||||
const plogRedact = pino({ redact: ['a.b.c'] }, dest)
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogAsyncRedact = require('../../')(
|
||||
{ redact: ['a.b.c'] },
|
||||
pino.destination({ dest: '/dev/null', sync: false })
|
||||
)
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogUnsafeRedact = require('../../')({ redact: ['a.b.c'], safe: false }, dest)
|
||||
delete require.cache[require.resolve('../../')]
|
||||
const plogUnsafeAsyncRedact = require('../../')(
|
||||
{ redact: ['a.b.c'], safe: false },
|
||||
pino.destination({ dest: '/dev/null', sync: false })
|
||||
)
|
||||
|
||||
const max = 10
|
||||
|
||||
// note that "redact me." is the same amount of bytes as the censor: "[Redacted]"
|
||||
|
||||
const run = bench([
|
||||
function benchPinoNoRedact (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plog.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoRedact (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogRedact.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoUnsafeNoRedact (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogUnsafe.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoUnsafeRedact (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogUnsafeRedact.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncNoRedact (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsync.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoAsyncRedact (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogAsyncRedact.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoUnsafeAsyncNoRedact (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogUnsafeAsync.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoUnsafeAsyncRedact (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogUnsafeAsyncRedact.info({ a: { b: { c: 'redact me.', d: 'leave me' } } })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
81
backend/node_modules/pino/benchmarks/long-string.bench.js
generated
vendored
Normal file
81
backend/node_modules/pino/benchmarks/long-string.bench.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
const bunyan = require('bunyan')
|
||||
const bole = require('bole')('bench')
|
||||
const winston = require('winston')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plogNodeStream = pino(dest)
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogDest = require('../')(pino.destination('/dev/null'))
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogMinLength = require('../')(pino.destination({ dest: '/dev/null', sync: false, minLength: 4096 }))
|
||||
|
||||
const crypto = require('crypto')
|
||||
|
||||
const longStr = crypto.randomBytes(2000).toString()
|
||||
|
||||
const max = 10
|
||||
const blog = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{
|
||||
level: 'trace',
|
||||
stream: dest
|
||||
}]
|
||||
})
|
||||
|
||||
require('bole').output({
|
||||
level: 'info',
|
||||
stream: dest
|
||||
}).setFastTime(true)
|
||||
|
||||
const chill = winston.createLogger({
|
||||
transports: [
|
||||
new winston.transports.Stream({
|
||||
stream: fs.createWriteStream('/dev/null')
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
const run = bench([
|
||||
function benchBunyan (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinston (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBole (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPino (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLength (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStream (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info(longStr)
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 1000)
|
||||
|
||||
run(run)
|
||||
193
backend/node_modules/pino/benchmarks/multi-arg.bench.js
generated
vendored
Normal file
193
backend/node_modules/pino/benchmarks/multi-arg.bench.js
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
const bunyan = require('bunyan')
|
||||
const bole = require('bole')('bench')
|
||||
const winston = require('winston')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const plogNodeStream = pino(dest)
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogDest = require('../')(pino.destination('/dev/null'))
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogMinLength = require('../')(pino.destination({ dest: '/dev/null', sync: false, minLength: 4096 }))
|
||||
delete require.cache[require.resolve('../')]
|
||||
|
||||
const deep = require('../package.json')
|
||||
deep.deep = Object.assign({}, JSON.parse(JSON.stringify(deep)))
|
||||
deep.deep.deep = Object.assign({}, JSON.parse(JSON.stringify(deep)))
|
||||
deep.deep.deep.deep = Object.assign({}, JSON.parse(JSON.stringify(deep)))
|
||||
|
||||
const blog = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{
|
||||
level: 'trace',
|
||||
stream: dest
|
||||
}]
|
||||
})
|
||||
|
||||
require('bole').output({
|
||||
level: 'info',
|
||||
stream: dest
|
||||
}).setFastTime(true)
|
||||
|
||||
const chill = winston.createLogger({
|
||||
transports: [
|
||||
new winston.transports.Stream({
|
||||
stream: fs.createWriteStream('/dev/null')
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamInterpolate (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello %s', 'world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBunyanInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
|
||||
function benchWinstonInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamInterpolateAll (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello %s %j %d', 'world', { obj: true }, 4)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBunyanInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamInterpolateExtra (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello %s %j %d', 'world', { obj: true }, 4, { another: 'obj' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBunyanInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.log('info', 'hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamInterpolateDeep (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info('hello %j', deep)
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
98
backend/node_modules/pino/benchmarks/multistream.js
generated
vendored
Normal file
98
backend/node_modules/pino/benchmarks/multistream.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const bunyan = require('bunyan')
|
||||
const pino = require('../')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
|
||||
const 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 }
|
||||
]
|
||||
const pinomsTen = pino({ level: 'debug' }, pino.multistream(tenStreams))
|
||||
|
||||
const fourStreams = [
|
||||
{ stream: dest },
|
||||
{ stream: dest },
|
||||
{ level: 'debug', stream: dest },
|
||||
{ level: 'trace', stream: dest }
|
||||
]
|
||||
const pinomsFour = pino({ level: 'debug' }, pino.multistream(fourStreams))
|
||||
|
||||
const pinomsOne = pino({ level: 'info' }, pino.multistream(dest))
|
||||
const blogOne = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{ stream: dest }]
|
||||
})
|
||||
|
||||
const blogTen = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: tenStreams
|
||||
})
|
||||
const blogFour = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: fourStreams
|
||||
})
|
||||
|
||||
const max = 10
|
||||
const run = bench([
|
||||
function benchBunyanTen (cb) {
|
||||
for (let 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 (let 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 benchBunyanFour (cb) {
|
||||
for (let i = 0; i < max; i++) {
|
||||
blogFour.info('hello world')
|
||||
blogFour.debug('hello world')
|
||||
blogFour.trace('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMSFour (cb) {
|
||||
for (let i = 0; i < max; i++) {
|
||||
pinomsFour.info('hello world')
|
||||
pinomsFour.debug('hello world')
|
||||
pinomsFour.trace('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBunyanOne (cb) {
|
||||
for (let i = 0; i < max; i++) {
|
||||
blogOne.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMSOne (cb) {
|
||||
for (let i = 0; i < max; i++) {
|
||||
pinomsOne.info('hello world')
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run()
|
||||
82
backend/node_modules/pino/benchmarks/object.bench.js
generated
vendored
Normal file
82
backend/node_modules/pino/benchmarks/object.bench.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
'use strict'
|
||||
|
||||
const bench = require('fastbench')
|
||||
const pino = require('../')
|
||||
const bunyan = require('bunyan')
|
||||
const bole = require('bole')('bench')
|
||||
const winston = require('winston')
|
||||
const fs = require('node:fs')
|
||||
const dest = fs.createWriteStream('/dev/null')
|
||||
const loglevel = require('./utils/wrap-log-level')(dest)
|
||||
const plogNodeStream = pino(dest)
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogDest = require('../')(pino.destination('/dev/null'))
|
||||
delete require.cache[require.resolve('../')]
|
||||
const plogMinLength = require('../')(pino.destination({ dest: '/dev/null', sync: false, minLength: 4096 }))
|
||||
const blog = bunyan.createLogger({
|
||||
name: 'myapp',
|
||||
streams: [{
|
||||
level: 'trace',
|
||||
stream: dest
|
||||
}]
|
||||
})
|
||||
require('bole').output({
|
||||
level: 'info',
|
||||
stream: dest
|
||||
}).setFastTime(true)
|
||||
const chill = winston.createLogger({
|
||||
transports: [
|
||||
new winston.transports.Stream({
|
||||
stream: fs.createWriteStream('/dev/null')
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
const max = 10
|
||||
|
||||
const run = bench([
|
||||
function benchBunyanObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
blog.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchWinstonObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
chill.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchBoleObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
bole.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchLogLevelObject (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
loglevel.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogDest.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoMinLengthObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogMinLength.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
},
|
||||
function benchPinoNodeStreamObj (cb) {
|
||||
for (var i = 0; i < max; i++) {
|
||||
plogNodeStream.info({ hello: 'world' })
|
||||
}
|
||||
setImmediate(cb)
|
||||
}
|
||||
], 10000)
|
||||
|
||||
run(run)
|
||||
36
backend/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js
generated
vendored
Normal file
36
backend/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict'
|
||||
const { join } = require('node:path')
|
||||
const { execSync } = require('node:child_process')
|
||||
|
||||
const run = (type) => {
|
||||
process.stderr.write(`benchmarking ${type}\n`)
|
||||
return execSync(`node ${join(__dirname, 'runbench')} ${type} -q`)
|
||||
}
|
||||
|
||||
console.log(`
|
||||
# Benchmarks
|
||||
|
||||
\`pino.info('hello world')\`:
|
||||
|
||||
\`\`\`
|
||||
${run('basic')}
|
||||
\`\`\`
|
||||
|
||||
\`pino.info({'hello': 'world'})\`:
|
||||
|
||||
\`\`\`
|
||||
${run('object')}
|
||||
\`\`\`
|
||||
|
||||
\`pino.info(aBigDeeplyNestedObject)\`:
|
||||
|
||||
\`\`\`
|
||||
${run('deep-object')}
|
||||
\`\`\`
|
||||
|
||||
\`pino.info('hello %s %j %d', 'world', {obj: true}, 4, {another: 'obj'})\`:
|
||||
|
||||
For a fair comparison, [LogLevel](http://npm.im/loglevel) was extended
|
||||
to include a timestamp and [bole](http://npm.im/bole) had
|
||||
\`fastTime\` mode switched on.
|
||||
`)
|
||||
138
backend/node_modules/pino/benchmarks/utils/runbench.js
generated
vendored
Normal file
138
backend/node_modules/pino/benchmarks/utils/runbench.js
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
'use strict'
|
||||
|
||||
const { type, platform, arch, release, cpus } = require('node:os')
|
||||
const { resolve, join } = require('node:path')
|
||||
const spawn = require('node:child_process').spawn
|
||||
const pump = require('pump')
|
||||
const split = require('split2')
|
||||
const through = require('through2')
|
||||
const steed = require('steed')
|
||||
|
||||
function usage () {
|
||||
console.log(`
|
||||
Pino Benchmarks
|
||||
|
||||
To run a benchmark, specify which to run:
|
||||
|
||||
・all ⁃ run all benchmarks (takes a while)
|
||||
・basic ⁃ log a simple string
|
||||
・object ⁃ logging a basic object
|
||||
・deep-object ⁃ logging a large object
|
||||
・multi-arg ⁃ multiple log method arguments
|
||||
・child ⁃ child from a parent
|
||||
・child-child ⁃ child from a child
|
||||
・child-creation ⁃ child constructor
|
||||
・formatters ⁃ difference between with or without formatters
|
||||
|
||||
Example:
|
||||
|
||||
node runbench basic
|
||||
`)
|
||||
}
|
||||
|
||||
if (!process.argv[2]) {
|
||||
usage()
|
||||
process.exit()
|
||||
}
|
||||
|
||||
const quiet = process.argv[3] === '-q'
|
||||
|
||||
const selectedBenchmark = process.argv[2].toLowerCase()
|
||||
const benchmarkDir = resolve(__dirname, '..')
|
||||
const benchmarks = {
|
||||
basic: 'basic.bench.js',
|
||||
object: 'object.bench.js',
|
||||
'deep-object': 'deep-object.bench.js',
|
||||
'multi-arg': 'multi-arg.bench.js',
|
||||
'long-string': 'long-string.bench.js',
|
||||
child: 'child.bench.js',
|
||||
'child-child': 'child-child.bench.js',
|
||||
'child-creation': 'child-creation.bench.js',
|
||||
formatters: 'formatters.bench.js'
|
||||
}
|
||||
|
||||
function runBenchmark (name, done) {
|
||||
const benchmarkResults = {}
|
||||
benchmarkResults[name] = {}
|
||||
|
||||
const processor = through(function (line, enc, cb) {
|
||||
const [label, time] = ('' + line).split(': ')
|
||||
const [target, iterations] = label.split('*')
|
||||
const logger = target.replace('bench', '')
|
||||
|
||||
if (!benchmarkResults[name][logger]) benchmarkResults[name][logger] = []
|
||||
|
||||
benchmarkResults[name][logger].push({
|
||||
time: time.replace('ms', ''),
|
||||
iterations: iterations.replace(':', '')
|
||||
})
|
||||
|
||||
cb()
|
||||
})
|
||||
|
||||
if (quiet === false) console.log(`Running ${name.toUpperCase()} benchmark\n`)
|
||||
|
||||
const benchmark = spawn(
|
||||
process.argv[0],
|
||||
[join(benchmarkDir, benchmarks[name])]
|
||||
)
|
||||
|
||||
if (quiet === false) {
|
||||
benchmark.stdout.pipe(process.stdout)
|
||||
}
|
||||
|
||||
pump(benchmark.stdout, split(), processor)
|
||||
|
||||
benchmark.on('exit', () => {
|
||||
console.log()
|
||||
if (done && typeof done === 'function') done(null, benchmarkResults)
|
||||
})
|
||||
}
|
||||
|
||||
function sum (arr) {
|
||||
let result = 0
|
||||
for (var i = 0; i < arr.length; i += 1) {
|
||||
result += Number.parseFloat(arr[i].time)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function displayResults (results) {
|
||||
if (quiet === false) console.log('==========')
|
||||
const benchNames = Object.keys(results)
|
||||
for (var i = 0; i < benchNames.length; i += 1) {
|
||||
console.log(`${benchNames[i].toUpperCase()} benchmark averages`)
|
||||
const benchmark = results[benchNames[i]]
|
||||
const loggers = Object.keys(benchmark)
|
||||
for (var j = 0; j < loggers.length; j += 1) {
|
||||
const logger = benchmark[loggers[j]]
|
||||
const average = sum(logger) / logger.length
|
||||
console.log(`${loggers[j]} average: ${average.toFixed(3)}ms`)
|
||||
}
|
||||
}
|
||||
if (quiet === false) {
|
||||
console.log('==========')
|
||||
console.log(
|
||||
`System: ${type()}/${platform()} ${arch()} ${release()}`,
|
||||
`~ ${cpus()[0].model} (cores/threads: ${cpus().length})`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function toBench (done) {
|
||||
runBenchmark(this.name, done)
|
||||
}
|
||||
|
||||
const benchQueue = []
|
||||
if (selectedBenchmark !== 'all') {
|
||||
benchQueue.push(toBench.bind({ name: selectedBenchmark }))
|
||||
} else {
|
||||
const keys = Object.keys(benchmarks)
|
||||
for (var i = 0; i < keys.length; i += 1) {
|
||||
benchQueue.push(toBench.bind({ name: keys[i] }))
|
||||
}
|
||||
}
|
||||
steed.series(benchQueue, function (err, results) {
|
||||
if (err) return console.error(err.message)
|
||||
results.forEach(displayResults)
|
||||
})
|
||||
55
backend/node_modules/pino/benchmarks/utils/wrap-log-level.js
generated
vendored
Normal file
55
backend/node_modules/pino/benchmarks/utils/wrap-log-level.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict'
|
||||
|
||||
const { readFileSync } = require('node:fs')
|
||||
const vm = require('vm')
|
||||
const { join } = require('node:path')
|
||||
const code = readFileSync(
|
||||
join(__dirname, '..', '..', 'node_modules', 'loglevel', 'lib', 'loglevel.js')
|
||||
)
|
||||
const { Console } = require('console')
|
||||
|
||||
function build (dest) {
|
||||
const sandbox = {
|
||||
module: {},
|
||||
console: new Console(dest, dest)
|
||||
}
|
||||
const context = vm.createContext(sandbox)
|
||||
|
||||
const script = new vm.Script(code)
|
||||
script.runInContext(context)
|
||||
|
||||
const loglevel = sandbox.log
|
||||
|
||||
const originalFactory = loglevel.methodFactory
|
||||
loglevel.methodFactory = function (methodName, logLevel, loggerName) {
|
||||
const rawMethod = originalFactory(methodName, logLevel, loggerName)
|
||||
|
||||
return function () {
|
||||
const time = new Date()
|
||||
let array
|
||||
if (typeof arguments[0] === 'string') {
|
||||
arguments[0] = '[' + time.toISOString() + '] ' + arguments[0]
|
||||
rawMethod.apply(null, arguments)
|
||||
} else {
|
||||
array = new Array(arguments.length + 1)
|
||||
array[0] = '[' + time.toISOString() + ']'
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
array[i + 1] = arguments[i]
|
||||
}
|
||||
rawMethod.apply(null, array)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loglevel.setLevel(loglevel.levels.INFO)
|
||||
return loglevel
|
||||
}
|
||||
|
||||
module.exports = build
|
||||
|
||||
if (require.main === module) {
|
||||
const loglevel = build(process.stdout)
|
||||
loglevel.info('hello')
|
||||
loglevel.info({ hello: 'world' })
|
||||
loglevel.info('hello %j', { hello: 'world' })
|
||||
}
|
||||
Reference in New Issue
Block a user