1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-02 19:52:32 +02:00

Fix benchmarks that use value.change (#2569)

* benchmark for large with selection

* inputer -> inputter

* value.change -> editor for slate benchmarks

* use editor in slate-react benchmarks

* prettier

* fix decorations benchmark
This commit is contained in:
Yoel
2019-01-30 13:10:34 -07:00
committed by Ian Storm Taylor
parent f677f76559
commit 8a0baac696
19 changed files with 160 additions and 64 deletions

View File

@@ -27,7 +27,7 @@ class Bench {
this.name = name
this.options = makeOptions({ ...suite.options, ...options })
this.isFinished = false
this.inputer = () => undefined
this.inputter = () => undefined
this.runner = () => {}
this.report = { ...errorReport }
suite.addBench(this)
@@ -45,22 +45,22 @@ class Bench {
/**
* Set the method to generate (different} inputs for each run
* @param {Array|Function|Scalar} inputer
* @param {Array|Function|Scalar} inputter
* @return {void}
*/
input(inputer) {
if (Array.isArray(inputer)) {
this.inputer = index => inputer[index % inputer.length]
input(inputter) {
if (Array.isArray(inputter)) {
this.inputter = index => inputter[index % inputter.length]
return
}
if (typeof inputer === 'function') {
this.inputer = inputer
if (typeof inputter === 'function') {
this.inputter = inputter
return
}
this.inputer = () => inputer
this.inputter = () => inputter
}
/**
@@ -84,7 +84,7 @@ class Bench {
async compose(times, initial) {
times = Math.floor(times)
const isAsync = this.options.async
const { runner, inputer } = this
const { runner, inputter } = this
const { maxTime } = this.options
let seq = Number.isFinite(this.options.maxTries) ? 1 : NaN
@@ -125,7 +125,7 @@ class Bench {
function runBundleTasks(tries, initialIndex) {
const inputs = Array.from({ length: tries }).map(index =>
inputer(index + initialIndex)
inputter(index + initialIndex)
)
const timer = new Timer()
timer.start()