Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test spreads1
(version: 0)
Comparing performance of:
Test array spread vs Test array concat vs Test array push vs Test object spread vs Test object assign
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var items = (new Array(1000).fill(0)).map((_, idx) => ({ id: idx, someProp: new Array(), also: false, maybe: 1, hmm: { id: idx + 1, id2: idx + 1 } }))
Tests:
Test array spread
const innerIds = items.reduce((acc, item) => [...acc, item.hmm.id, item.hmm.id2], []);
Test array concat
const innerIds = items.reduce((acc, item) => acc.concat(item.hmm.id, item.hmm.id2), []);
Test array push
const innerIds = items.reduce((acc, item) => { acc.push(item.hmm.id); acc.push(item.hmm.id2); return acc}, []);
Test object spread
const objectSet = items.reduce((acc, item) => ({...acc, [item.id]: item}), {});
Test object assign
const objectSet = items.reduce((acc, item) => Object.assign(acc, {[item.id]: item}), {});
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Test array spread
Test array concat
Test array push
Test object spread
Test 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:
Fill vs spread
Array range generating
Object spread vs New map
unshift vs spread
Comments
Confirm delete:
Do you really want to delete benchmark?