1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 13:18:29 +01:00
slate/support/benchmark/reporter.js
2018-02-06 19:41:03 -08:00

32 lines
615 B
JavaScript

const { stdout } = process
module.exports = function(runner, utils) {
let hasSuite = false
let hasBench = false
runner.on('start', () => {
stdout.write('[')
})
runner.on('end', () => {
stdout.write(']')
})
runner.on('suite start', suite => {
if (hasSuite) stdout.write(',')
stdout.write(`{"name":"${suite.title}","benchmarks":[`)
hasSuite = true
})
runner.on('suite end', suite => {
hasBench = false
stdout.write(']}')
})
runner.on('bench end', bench => {
if (hasBench) stdout.write(',')
stdout.write(JSON.stringify(bench))
hasBench = true
})
}