1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 19:01:54 +02:00

change slate to be a monorepo using lerna (#1106)

* init lerna, move files into ./packages

* move test files into ./packages

* more moving around

* fill out package.json files

* fixing imports

* more fixing of imports, and horribleness

* convert examples, fix linting errors

* add documentation

* update docs

* get tests passing

* update travis.yml

* update travis.yml

* update travis.yml

* update test script

* update travis.yml

* update scripts

* try simplifying travis.yml

* ocd stuff

* remove slate-core-test-helpers package

* add package readmes

* update reference docs structure

* refactor slate-simulator into its own package

* add docs for new packages

* update docs

* separate benchmarks into packages, and refactor them
This commit is contained in:
Ian Storm Taylor
2017-09-11 18:11:45 -07:00
committed by GitHub
parent 4d73f19dc7
commit ace9f47930
687 changed files with 3337 additions and 15035 deletions

View File

@@ -0,0 +1,48 @@
/* eslint-disable no-console */
import chalk from 'chalk'
import baseline from '../tmp/benchmark-baseline'
import comparison from '../tmp/benchmark-comparison'
/**
* Constants.
*/
const THRESHOLD = 0.2
/**
* Print.
*/
console.log()
console.log(` benchmarks`)
baseline.forEach((suite, i) => {
console.log(` ${suite.name}`)
suite.benchmarks.forEach((base, j) => {
const comp = comparison[i].benchmarks[j]
if (!comp) return
const b = base.iterations / base.elapsed * 100
const c = comp.iterations / comp.elapsed * 100
const threshold = b * THRESHOLD
const slower = (b - c) > threshold
const faster = (b - c) < (0 - threshold)
const percent = Math.round(Math.abs(b - c) / b * 100)
let output = `${b.toFixed(2)}${c.toFixed(2)} iterations/sec`
if (slower) output = chalk.red(`${output} (${percent}% slower)`)
else if (faster) output = chalk.green(`${output} (${percent}% faster)`)
else output = chalk.gray(output)
if (percent > 1000) output += ' 😱'
else if (faster && percent > 100) output += ' 🙌'
else if (slower && percent > 100) output += ' 😟'
console.log(` ${base.title}`)
console.log(` ${output}`)
})
})
console.log()

View File

@@ -0,0 +1,32 @@
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
})
}