Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Reduce test
(version: 1)
Comparing performance of:
Reduce (reuse object) vs Reduce (creating temporary objects)
Created:
5 months ago
by:
Guest
Jump to the latest result
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)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Reduce (reuse object)
Reduce (creating temporary objects)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
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/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Reduce (reuse object)
188.7 Ops/sec
Reduce (creating temporary objects)
442.9 Ops/sec
Related benchmarks:
PwD84cTUCbiv4QqfvngndfD7u8sXdFuW-2
__proto__ vs. create
[Object.entries after fixed] Reduce vs Looping vs Ifs vs Destructuring vs Object.entries vs Single loop vs Single reduce vs Template string vs Template function
[Object.entries after fixed] Reduce vs Looping vs Ifs vs Destructuring vs Object.entries vs Single loop vs Single reduce vs Template string vs Template function2
[Object.entries after fixed] Reduce vs Looping vs Ifs vs Destructuring vs Object.entries vs Single loop vs Single reduce vs Template string vs Template shared2
nbdfdf
Test dgdfgdfgfg
test +0
i++ ++i i += 1
Comments
Confirm delete:
Do you really want to delete benchmark?