add hw2
This commit is contained in:
67
node_modules/pino/benchmarks/internal/custom-levels.js
generated
vendored
Normal file
67
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
node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js
generated
vendored
Normal file
76
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('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
node_modules/pino/benchmarks/internal/just-pino.bench.js
generated
vendored
Normal file
182
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('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
node_modules/pino/benchmarks/internal/parent-vs-child.bench.js
generated
vendored
Normal file
75
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
node_modules/pino/benchmarks/internal/redact.bench.js
generated
vendored
Normal file
86
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('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)
|
||||
Reference in New Issue
Block a user