Skip to content
Myr

Merge pull request #1187 from immerjs/feature/more-benchmarks-3

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

Add second large object test to check v8 non-fast properties

authored by Mark Erikson · committed by GitHub · parents 3955eed, 8b341a5 · Browse files · 1 file+37 added−34 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+37 added−34 removed

  • other:+37 added−34 removed

1 file+37 added−34 removed

modified:perf-testing/immutability-benchmarks.mjs+37 added-34 removed
42 unmodified lines
43 id: i,44 name: `name-${i}`,45 isActive: i % 2 === 046 })),47 largeObject: createLargeObject(BENCHMARK_CONFIG.largeObjectSize),47 largeObject1: createLargeObject(BENCHMARK_CONFIG.largeObjectSize1),48 largeObject2: createLargeObject(BENCHMARK_CONFIG.largeObjectSize2),49 api: {50 queries: {},51 provided: {52 keys: {}
9 unmodified lines
62const BENCHMARK_CONFIG = {63 iterations: 1,64 arraySize: 100,65 nestedArraySize: 10,65 largeObjectSize: 1000,66 largeObjectSize1: 1000,67 largeObjectSize2: 3000,68 multiUpdateCount: 5,69 reuseStateIterations: 1070}71
33 unmodified lines
105const update = index => ({106 type: "test/updateItem",107 payload: {id: index, value: index, nestedData: index}108})107const updateLargeObject = index => ({108 type: "test/updateLargeObject",109const updateLargeObject1 = index => ({110 type: "test/updateLargeObject1",111 payload: {value: index}112})113const updateLargeObject2 = index => ({114 type: "test/updateLargeObject2",115 payload: {value: index}116})117const concat = index => ({118 type: "test/concatArray",119 payload: Array.from({length: 500}, (_, i) => ({id: i, value: index}))120})
58 unmodified lines
179 add,180 remove,181 filter,182 update,177 updateLargeObject,183 concat,184 mapNested,185 // dash-named fields to improve readability in benchmark results186187 "update-largeObject1": updateLargeObject1,188 "update-largeObject2": updateLargeObject2,189 "update-high": updateHigh,190 "update-multiple": updateMultiple,191 "remove-high": removeHigh,192 "sortById-reverse": sortByIdReverse,
146 unmodified lines
339 : item340 )341 }342 }335 case "test/updateLargeObject": {343 case "test/updateLargeObject1": {344 return {345 ...state,338 largeObject: {339 ...state.largeObject,346 largeObject1: {347 ...state.largeObject1,348 [`propertyAdded${action.payload.value}`]: {349 id: action.payload.value350 }351 }352 }353 }354 case "test/updateLargeObject2": {355 return {356 ...state,357 largeObject2: {358 ...state.largeObject2,359 [`propertyAdded${action.payload.value}`]: {360 id: action.payload.value361 }362 }363 }364 }365 case "test/concatArray": {366 const length = state.largeArray.length367 const newArray = action.payload.concat(state.largeArray)368 newArray.length = length
111 unmodified lines
480 item.value = action.payload.value481 item.nested.data = action.payload.nestedData482 break483 }465 case "test/updateLargeObject": {466 draft.largeObject[`propertyAdded${action.payload.value}`] = {484 case "test/updateLargeObject1": {485 draft.largeObject1[`propertyAdded${action.payload.value}`] = {486 id: action.payload.value487 }488 break489 }490 case "test/updateLargeObject2": {491 draft.largeObject2[`propertyAdded${action.payload.value}`] = {492 id: action.payload.value493 }494 break495 }496 case "test/concatArray": {497 const length = state.largeArray.length498 const newArray = action.payload.concat(state.largeArray)499 newArray.length = length
121 unmodified lines
621 "update",622 "update-high",623 "remove",624 "remove-high",600 "updateLargeObject"625 "update-largeObject1",626 "update-largeObject2"627 ]628 for (const action of reuseActions) {629 summary(function() {630 bench(`$action-reuse: $version (freeze: $freeze)`, function*(args) {
585 unmodified lines
1216 console.log("No version data available for overall rankings.")1217 return1218 }12191194 console.log(1195 "\nMethodology: Lower geometric mean = better overall performance"1196 )1197 console.log(1198 "(Geometric mean is standard for benchmarking as it handles multiplicative performance differences)"1199 )12001220 console.log("\n┌──────┬─────────────────────┬─────────────────┬───────────┐")1221 console.log("│ Rank │ Version │ Geometric Mean │ Scenarios │")1222 console.log("├──────┼─────────────────────┼─────────────────┼───────────┤")1223
10 unmodified lines
1234 console.log(`│ ${rank} │ ${displayName} │ ${geoMean} │ ${scenarios} │`)1235 }12361237 console.log("└──────┴─────────────────────┴─────────────────┴───────────┘")12191220 // Highlight top performers1221 if (versionScores.length >= 3) {1222 console.log("\nTop Overall Performers:")1223 for (let i = 0; i < Math.min(10, versionScores.length); i++) {1224 const score = versionScores[i]1225 const [versionName, freezeIndicator] = score.version.split("|")1226 const shortName = shortenVersionName(versionName)1227 console.log(1228 ` ${i +1229 1}. ${shortName} (${freezeIndicator}) - ${score.geometricMean.toFixed(1230 21231 )}x average`1232 )1233 }1234 }1238}12391240function printBenchmarkSummaryTable(benchmarks) {1241 try {
43 unmodified lines