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 (Macintosh; Intel Mac OS X 10.15; rv:142.0) Gecko/20100101 Firefox/142.0
Browser:
Firefox 142
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
8 months ago
Test name
Executions per second
for of
15861.1 Ops/sec
map
89718.8 Ops/sec
bad map
107825.2 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; })