Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Performance of JavaScript .forEach, .map and .reduce vs for and for..of (fork)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36 EdgA/126.0.0.0
Browser:
Chrome Mobile 126
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
raw iteration: for..of
64/s
raw iteration: forEach
63/s
reduce comparision: for..of
60/s
reduce comparision: .reduce
49/s
map comparison: .map
45/s
map comparison: for..of
26/s
View exact numbers
Test name
Executions per second
✓
raw iteration: for..of
64 Ops/sec
raw iteration: forEach
63 Ops/sec
reduce comparision: for..of
60 Ops/sec
reduce comparision: .reduce
49 Ops/sec
map comparison: .map
45 Ops/sec
map comparison: for..of
26 Ops/sec
Script Preparation code:
function generateTestArray() { const result = []; for (let i = 0; i < 1000000; ++i) { result.push(i); } return result; } window.array = generateTestArray();
Tests:
map comparison: for..of
const r = []; for(const x of array) { r.push(x); }
map comparison: .map
array.map(x => x)
reduce comparision: for..of
let r = 0; for (const x of array) { r += x; }
reduce comparision: .reduce
array.reduce((p, x) => p + x, 0);
raw iteration: for..of
for(const x of array) {}
raw iteration: forEach
array.forEach(x => {})