Spread vs Assign

Benchmark created on


Setup

data = [...Array(1000).keys()].map(() => ({test: {[`a${Math.random()}`]: Math.random()}}))

Test runner

Ready to run.

Testing in
TestOps/sec
Map + Assign
Object.assign({}, ...data.map(a => a.test))
ready
Reduce + Spread
data.reduce((acc, cur) => ({...acc, ...cur.test}), {})
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.