Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Reduce and Spread vs. Foreach and Mutate (for Kafka.js)
(version: 0)
Comparing performance of:
Reduce and Spread vs ForEach and Mutate (for .. in loop) vs Mutate with Object.assign vs Foreach and Mutate (Object.assign)
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var objectsArray = Array(10000).fill(() => { const key = Math.random().toString(36).substring(2, 5); const value = Math.random().toString(36).substring(2, 5); return {[key]: value}; });
Tests:
Reduce and Spread
var combined = objectsArray.reduce((memo, obj) => ({...memo, ...obj}), {});
ForEach and Mutate (for .. in loop)
var combined = {} objectsArray.forEach(obj => { for (key in obj) { combined[key] = obj[key]; } });
Mutate with Object.assign
var combined = Object.assign(...objectsArray)
Foreach and Mutate (Object.assign)
var combined = {} objectsArray.forEach(obj => Object.assign(combined, obj));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Reduce and Spread
ForEach and Mutate (for .. in loop)
Mutate with Object.assign
Foreach and Mutate (Object.assign)
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!
Related benchmarks:
Reduce and Spread vs. Foreach and Mutate
Reduce and Spread vs. Foreach and Mutate (fewer, but larger, objects)
Reduce and Spread vs. Foreach and Mutate 2
Reduce and Spread vs. Foreach and Mutate 3
Comments
Confirm delete:
Do you really want to delete benchmark?