Skip to content
Myr

Improve filtering test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Mark Erikson · committed by Mark Erikson · parent 6e51eb6 · Browse files · 1 file+10 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−3 removed

  • other:+10 added−3 removed

1 file+10 added−3 removed

modified:perf-testing/immutability-benchmarks.mjs+10 added-3 removed
72 unmodified lines
73 type: "test/addItem",74 payload: {id: index, value: index, nested: {data: index}}75})76const remove = index => ({type: "test/removeItem", payload: index})77const filter = index => ({type: "test/filterItem", payload: index})77const filter = percentToKeep => ({78 type: "test/filterItem",79 payload: percentToKeep80})81const update = index => ({82 type: "test/updateItem",83 payload: {id: index, value: index, nestedData: index}84})
72 unmodified lines
157 largeArray: newArray158 }159 }160 case "test/filterItem": {161 const keepPercentage = action.payload / 10162 const length = state.largeArray.length163 const newArray = state.largeArray.filter(159 (item, i) => i !== action.payload164 (item, i) => i / length < action.payload165 )166 return {167 ...state,168 largeArray: newArray
37 unmodified lines
206 case "test/removeItem":207 draft.largeArray.splice(action.payload, 1)208 break209 case "test/filterItem": {210 const keepPercentage = action.payload / 10211 const length = state.largeArray.length212 draft.largeArray = draft.largeArray.filter(206 (item, i) => i !== action.payload213 (item, i) => i / length < action.payload214 )215 break216 }217 case "test/updateItem": {
69 unmodified lines