Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for-of-vs-map-bad
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 17
Operating system:
iOS 17.5.1
Device Platform:
Mobile
Date tested:
7 months ago
Test name
Executions per second
for of
92674.2 Ops/sec
map
61354.9 Ops/sec
bad map
92321.4 Ops/sec
Script Preparation code:
var arr = []; for (var i = 0; i < 1000; i++) { arr[i] = { name: `${i}`, value: i }; } function someFn(i) { const x24 = i.value * 3 * 8; i.value = x24; i.name = `${x24}`; return i; }
Tests:
for of
const x = Array(arr.length) for (var y of arr) { x.push(someFn(y)); }
map
const x = arr.map(item => someFn(item))
bad map
const x = arr.map((i) => { const x24 = i.value * 3 * 8; i.value = x24; i.name = `${x24}`; return i; })