Skip to content

Commit

Permalink
refactor(reactive): add benchmark scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed May 7, 2021
1 parent 93f5e7d commit 6954a1f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
38 changes: 38 additions & 0 deletions packages/reactive/benchmark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import b from 'benny'
import _ from 'lodash'
import * as mobx from 'mobx'
import * as vueReactivity from '@vue/reactivity'
import * as formilyReactive from './src'

function func(obs, times) {
obs.arr = []
obs.obj = {}
_.times(times, (v) => {
obs.num = v
obs.str = `${v}`
obs.arr.push(v)
obs.obj[`${v}`] = v
})
}

b.suite(
'Reactive Observable',

b.add('Case MobX', () => {
const obs = mobx.observable({})
func(obs, 1e3)
}),

b.add('Case @vue/reactivity', () => {
const obs = vueReactivity.reactive({})
func(obs, 1e3)
}),

b.add('Case @formily/reactive', () => {
const obs = formilyReactive.observable({})
func(obs, 1e3)
}),

b.cycle(),
b.complete()
)
11 changes: 8 additions & 3 deletions packages/reactive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@
"build:cjs": "tsc --declaration",
"build:esm": "tsc --declaration --module es2015 --outDir esm",
"build:umd": "rollup --config",
"build:docs": "dumi build"
"build:docs": "dumi build",
"benchmark": "ts-node ./benchmark"
},
"devDependencies": {
"dumi": "^1.1.0-rc.8"
"dumi": "^1.1.0-rc.8",
"benny": "^3.6.15",
"@vue/reactivity": "^3.0.11",
"lodash": "^4.17.21",
"mobx": "^6.3.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "2c44ae410a73f02735c63c6430e021a50e21f3ec"
}
}

0 comments on commit 6954a1f

Please sign in to comment.