1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 10:29:48 +02:00

Add teardown for benchmarks, and adapt memoize-utils benchmark

This commit is contained in:
Soreine
2016-11-03 13:19:55 +01:00
parent e505b7a159
commit bada4fa3f1
2 changed files with 12 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ const { default: memoize } = require('../../../lib/utils/memoize')
module.exports = {
setup(state) {
window.__NO_MEMOIZE = false
let obj = {
fibonacci(n = 20) {
if (n === 0 || n === 1) {
@@ -18,5 +20,11 @@ module.exports = {
run(obj) {
obj.fibonacci()
// Clear cache for next runs
delete obj.__cache
},
teardown() {
window.__NO_MEMOIZE = true
}
}

View File

@@ -110,6 +110,10 @@ function runBenchmarks() {
fn() {
scope.benchmark.run(state) // eslint-disable-line no-undef
// Next call will use another State instance
},
onComplete() {
global.getScope().benchmark.teardown()
}
}))
}