mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-21 05:42:00 +02:00
Add memoize-util benchmark
This commit is contained in:
parent
13d7cb07c6
commit
0dc3c4ef8a
22
perf/benchmarks/memoize-util/index.js
Normal file
22
perf/benchmarks/memoize-util/index.js
Normal file
@ -0,0 +1,22 @@
|
||||
const { default: memoize } = require('../../../lib/utils/memoize')
|
||||
|
||||
module.exports = {
|
||||
setup(state) {
|
||||
let obj = {
|
||||
fibonacci(n) {
|
||||
if (n === 0 || n === 1) {
|
||||
return n
|
||||
} else {
|
||||
return this.fibonacci(n - 1) + this.fibonacci(n - 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memoize(obj, ['fibonacci'])
|
||||
return obj
|
||||
},
|
||||
|
||||
run(obj) {
|
||||
obj.fibonacci(20)
|
||||
}
|
||||
}
|
6
perf/benchmarks/memoize-util/input.yaml
Normal file
6
perf/benchmarks/memoize-util/input.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
nodes:
|
||||
- kind: block
|
||||
type: paragraph
|
||||
nodes:
|
||||
- kind: text
|
||||
text: 'Useless input state'
|
Loading…
x
Reference in New Issue
Block a user