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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -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()
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
Reference in New Issue
Block a user