Skip to content

Commit

Permalink
Merge pull request #447 from pinojs/v5-docs
Browse files Browse the repository at this point in the history
V5 docs
  • Loading branch information
David Mark Clements committed Jul 18, 2018
2 parents deffbb0 + f4683d2 commit 1c7bb0f
Show file tree
Hide file tree
Showing 20 changed files with 1,611 additions and 1,258 deletions.
437 changes: 51 additions & 386 deletions README.md

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions benchmarks/utils/generate-benchmark-doc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict'
const { join } = require('path')
const { execSync } = require('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.
`)
23 changes: 15 additions & 8 deletions benchmarks/utils/runbench.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ if (!process.argv[2]) {
process.exit()
}

const quiet = process.argv[3] === '-q'

const selectedBenchmark = process.argv[2].toLowerCase()
const benchmarkDir = resolve(__dirname, '..')
const benchmarks = {
Expand Down Expand Up @@ -66,14 +68,17 @@ function runBenchmark (name, done) {
cb()
})

console.log(`Running ${name.toUpperCase()} benchmark\n`)
if (quiet === false) console.log(`Running ${name.toUpperCase()} benchmark\n`)

const benchmark = spawn(
process.argv[0],
[join(benchmarkDir, benchmarks[name])]
)

benchmark.stdout.pipe(process.stdout)
if (quiet === false) {
benchmark.stdout.pipe(process.stdout)
}

pump(benchmark.stdout, split(), processor)

benchmark.on('exit', () => {
Expand All @@ -91,7 +96,7 @@ function sum (arr) {
}

function displayResults (results) {
console.log('==========')
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`)
Expand All @@ -103,11 +108,13 @@ function displayResults (results) {
console.log(`${loggers[j]} average: ${average.toFixed(3)}ms`)
}
}
console.log('==========')
console.log(
`System: ${type()}/${platform()} ${arch()} ${release()}`,
`~ ${cpus()[0].model} (cores/threads: ${cpus().length})`
)
if (quiet === false) {
console.log('==========')
console.log(
`System: ${type()}/${platform()} ${arch()} ${release()}`,
`~ ${cpus()[0].model} (cores/threads: ${cpus().length})`
)
}
}

function toBench (done) {
Expand Down

0 comments on commit 1c7bb0f

Please sign in to comment.