Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Transform: Object.fromEntries vs reduce (large dataset)
(version: 0)
Comparing performance of:
Object.fromEntries (with transform data) vs Reduce (reuse object) vs Reduce (creating temporary objects)
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var ENTRIES = 10000; var data = Array.from(Array(ENTRIES).keys()).map(key => ({id: key, someProp: key + 1})) var createObject = (value) => ({ ...value, id: value.id, });
Tests:
Object.fromEntries (with transform data)
Object.fromEntries(data.map((key, value) => { const newValue = createObject(value); return [key, newValue]; }));
Reduce (reuse object)
data.reduce((acc, current) => { const newObj = createObject(current); acc[newObj.id] = newObj; return acc; }, {});
Reduce (creating temporary objects)
data.reduce((acc, current) => { const newObj = createObject(current); return { ...acc, [newObj.id]: newObj } }, {});
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Object.fromEntries (with transform data)
Reduce (reuse object)
Reduce (creating temporary objects)
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?