mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-05 06:47:26 +02:00
Add memoize-util benchmark
This commit is contained in:
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'
|
Reference in New Issue
Block a user