mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-31 19:01:54 +02:00
Add teardown for benchmarks, and adapt memoize-utils benchmark
This commit is contained in:
@@ -2,6 +2,8 @@ const { default: memoize } = require('../../../lib/utils/memoize')
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setup(state) {
|
setup(state) {
|
||||||
|
window.__NO_MEMOIZE = false
|
||||||
|
|
||||||
let obj = {
|
let obj = {
|
||||||
fibonacci(n = 20) {
|
fibonacci(n = 20) {
|
||||||
if (n === 0 || n === 1) {
|
if (n === 0 || n === 1) {
|
||||||
@@ -18,5 +20,11 @@ module.exports = {
|
|||||||
|
|
||||||
run(obj) {
|
run(obj) {
|
||||||
obj.fibonacci()
|
obj.fibonacci()
|
||||||
|
// Clear cache for next runs
|
||||||
|
delete obj.__cache
|
||||||
|
},
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
window.__NO_MEMOIZE = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -110,6 +110,10 @@ function runBenchmarks() {
|
|||||||
fn() {
|
fn() {
|
||||||
scope.benchmark.run(state) // eslint-disable-line no-undef
|
scope.benchmark.run(state) // eslint-disable-line no-undef
|
||||||
// Next call will use another State instance
|
// Next call will use another State instance
|
||||||
|
},
|
||||||
|
|
||||||
|
onComplete() {
|
||||||
|
global.getScope().benchmark.teardown()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user