Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
reduce + spread vs map + flat
(version: 1)
Comparing performance of:
reduce + spread vs map + flat
Created:
one year ago
by:
Registered User
Go to the latest result
Script Preparation code:
function generateTestArray() { const result = []; for (let i = 0; i < 1000; ++i) { result.push({ a: [i, i * 2, i * 3] }); } return result; }
Tests:
reduce + spread
const arr = generateTestArray(); const result = arr.reduce((acc, el) => { acc.push(...el.a); return acc; }, []);
map + flat
const arr = generateTestArray(); const result = arr.map(el => el.a).flat();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
reduce + spread
map + flat
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0
Browser/OS:
Opera 119 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
reduce + spread
42K/s
map + flat
19K/s
View exact numbers
Test name
Executions per second
✓
reduce + spread
42,497 Ops/sec
map + flat
19,212 Ops/sec
Related benchmarks
Performance of JavaScript .forEach, .map and .reduce vs for and for..of
Performance of JavaScript .forEach, .map and .reduce vs for and for..of (fork)
Performance of JavaScript .forEach, .map and .reduce vs for and for..of with 1000p
Performance of JavaScript .forEach, .map and .reduce vs for and for..of 2232132
Comments
Confirm delete:
Do you really want to delete benchmark?