Skip to content
Myr

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

4 files+36 added−1 removed

modified:__performance_tests__/add-data.js+10 added
modified:__performance_tests__/todo.js+21 added-1 removed
1"use strict"2import produce, {setAutoFreeze, setUseProxies} from "../dist/immer.umd.js"3import cloneDeep from "lodash.clonedeep"4import {List, Record} from "immutable"5import Seamless from "seamless-immutable"6import deepFreeze from "deep-freeze"78function freeze(x) {9 Object.freeze(x)10 return x11}1213describe("performance", () => {13 const MAX = 10000014 const MAX = 1000015 const MODIFY_FACTOR = 0.116 const baseState = []17 let frozenBazeState18 let immutableJsBaseState19 let seamlessBaseState2021 // produce the base state22 for (let i = 0; i < MAX; i++) {23 baseState.push({
13 unmodified lines
37 someThingCompletelyIrrelevant: []38 })39 immutableJsBaseState = List(baseState.map(todo => todoRecord(todo)))4041 // generate seamless-immutable base state42 seamlessBaseState = Seamless.from(baseState)4344 function measure(name, fn) {45 global.gc && global.gc()46 test(name, fn)47 }
96 unmodified lines
144 })145 .toJS()146 })147148 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 })154155 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 })162163 measure("immer (proxy) - without autofreeze", () => {164 setUseProxies(true)165 setAutoFreeze(false)166 produce(baseState, draft => {
36 unmodified lines
modified:package.json+1 added
modified:yarn.lock+4 added
3781 unmodified lines
3782sax@^1.2.1:3783 version "1.2.4"3784 resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"37853786seamless-immutable@^7.1.3:3787 version "7.1.3"3788 resolved "https://registry.yarnpkg.com/seamless-immutable/-/seamless-immutable-7.1.3.tgz#d32a8a202a331dffa69e4069a367a2159252490e"37893790semver-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