Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Reduce test
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Windows
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
Reduce (reuse object)
188.7 Ops/sec
Reduce (creating temporary objects)
442.9 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function generateNestedObject(level1Count, level2Count) { const result = {}; for (let i = 0; i < level1Count; i++) { result[i] = {}; for (let j = 0; j < level2Count; j++) { result[i][j] = { defaultValue: "", testId: `Field_${i}_${j}`, type: "text", labelText: `Label_${i}_${j}`, }; } } return result; } const bigObject = generateNestedObject(1000, 50);
Tests:
Reduce (reuse object)
const getReuseObject = (object) => Object.keys(object).reduce( (obj, key) => ({ ...obj, [key]: Object.keys(object[key]).reduce( (obj1, key1) => ({ ...obj1, [key1]: object[key][key1].defaultValue, }), {}, ), }), {}, ); getReuseObject(bigObject)
Reduce (creating temporary objects)
const getTemporaryObject = (object) => Object.keys(object).reduce((obj, key) => { const newObj = { ...obj }; const object1 = object[key]; newObj[key] = Object.keys(object1).reduce((obj1, key1) => { const newObj1 = { ...obj1 }; newObj1[key1] = object1[key1].defaultValue; return newObj1; }, {}); return newObj; }, {}); getTemporaryObject(bigObject)