added seamless-immutable to performance tests
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Christian Pekeler · committed by Christian Pekeler · parent 6e60eb5 · Browse files · 4 files·+36 added−1 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+36 added−1 removed
- other:+36 added−1 removed
Provenance
- Commit
1b2efe4- Tree
9b6df4d- Author
Christian Pekeler <christian@pekeler.org>- Committer
Christian Pekeler <christian@pekeler.org>- Parent
6e60eb5
4 files changed+36 added−1 removed
modified:__performance_tests__/add-data.js+10 added
123456789101112131415161718192041 unmodified lines6263646566676869707172737475767728 unmodified lines"use strict"
import produce, {setAutoFreeze, setUseProxies} from "../dist/immer.umd.js"import cloneDeep from "lodash.clonedeep"import {fromJS} from "immutable"import Seamless from "seamless-immutable"import deepFreeze from "deep-freeze"
describe("loading large set of data", () => { const dataSet = require("./data.json") const baseState = { data: null } const frozenBazeState = deepFreeze(cloneDeep(baseState)) const immutableJsBaseState = fromJS(baseState) const seamlessBaseState = Seamless.from(baseState)
function measure(name, fn) { global.gc && global.gc() test(name, fn)41 unmodified lines }) .toJS() })
measure("seamless-immutable", () => { seamlessBaseState.set("data", dataSet) })
measure("seamless-immutable + asMutable", () => { seamlessBaseState.set("data", dataSet).asMutable({deep: true}) })
measure("immer (proxy) - without autofreeze", () => { setUseProxies(true) setAutoFreeze(false) produce(baseState, draft => {28 unmodified linesmodified:__performance_tests__/todo.js+21 added-1 removed
1 "use strict"2 import produce, {setAutoFreeze, setUseProxies} from "../dist/immer.umd.js"3 import cloneDeep from "lodash.clonedeep"4 import {List, Record} from "immutable"5+import Seamless from "seamless-immutable"6 import deepFreeze from "deep-freeze"7 8 function freeze(x) {9 Object.freeze(x)10 return x11 }12 13 describe("performance", () => {13- const MAX = 10000014+ const MAX = 1000015 const MODIFY_FACTOR = 0.116 const baseState = []17 let frozenBazeState18 let immutableJsBaseState19+ let seamlessBaseState20 21 // produce the base state22 for (let i = 0; i < MAX; i++) {23 baseState.push({13 unmodified lines37 someThingCompletelyIrrelevant: []38 })39 immutableJsBaseState = List(baseState.map(todo => todoRecord(todo)))40 41+ // generate seamless-immutable base state42+ seamlessBaseState = Seamless.from(baseState)43+44 function measure(name, fn) {45 global.gc && global.gc()46 test(name, fn)47 }96 unmodified lines144 })145 .toJS()146 })147 148+ measure("seamless-immutable", () => {149+ let state = seamlessBaseState150+ for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {151+ state = state.setIn([i, "done"], true)152+ }153+ })154+155+ measure("seamless-immutable + asMutable", () => {156+ let state = seamlessBaseState157+ for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {158+ state = state.setIn([i, "done"], true)159+ }160+ state.asMutable({deep: true})161+ })162+163 measure("immer (proxy) - without autofreeze", () => {164 setUseProxies(true)165 setAutoFreeze(false)166 produce(baseState, draft => {36 unmodified linesmodified:package.json+1 added
65 unmodified lines66676869707172737412 unmodified lines65 unmodified lines "rollup-plugin-commonjs": "^8.2.6", "rollup-plugin-filesize": "^1.5.0", "rollup-plugin-node-resolve": "^3.0.2", "rollup-plugin-uglify": "^2.0.1", "seamless-immutable": "^7.1.3", "typescript": "^2.6.2", "uglify-es": "^3.3.6", "yarn-or-npm": "^2.0.4" },12 unmodified linesmodified:yarn.lock+4 added
3781 unmodified lines3782 sax@^1.2.1:3783 version "1.2.4"3784 resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"3785 3786+seamless-immutable@^7.1.3:3787+ version "7.1.3"3788+ resolved "https://registry.yarnpkg.com/seamless-immutable/-/seamless-immutable-7.1.3.tgz#d32a8a202a331dffa69e4069a367a2159252490e"3789+3790 semver-diff@^2.0.0:3791 version "2.1.0"3792 resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36"3793 dependencies:632 unmodified lines