Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
reduce+concat vs. for loops
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
reduce+concat+forEach
47795.5 Ops/sec
for loops
53562.5 Ops/sec
Script Preparation code:
DATA = Array.from({length:10}, (_, idx) => ({ idx, containers: Array.from({length: 10}, (_, container) => ({ title: 'hello', container })) }))
Tests:
reduce+concat+forEach
DATA .reduce((prev, cur) => prev.concat(cur.containers), []) .forEach((element, idx) => { Object.assign(element, { idx }); });
for loops
for (const page of DATA) { for (let i = 0; i < page.containers.length; ++i) { Object.assign(page.containers[i], { idx: i }); } }