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:
11 months ago
by:
Registered User
Jump 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:
11 months 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
Test name
Executions per second
reduce + spread
42496.7 Ops/sec
map + flat
19212.0 Ops/sec
Related benchmarks:
Performance of JavaScript .forEach, .map and .reduce vs for and for..of
map vs for vs for (init array)
map vs reduce
ak;ldjf;lakdjf
Performance of JavaScript .forEach, .map and .reduce vs for and for..ofCXCcccc
Performance of JavaScript .forEach, .map and .reduce vs for and for..of (fork)
Performance of JavaScript .forEach, .map and .reduce vs for and for..of2
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?