Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for-of-vs-map-bad
(version: 1)
Comparing performance of:
for of vs map vs bad map
Created:
8 months ago
by:
Guest
Jump to the latest result
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; })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
for of
map
bad map
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
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/OS:
Mobile Safari 17 on iOS 17.5.1
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
for of
92674.2 Ops/sec
map
61354.9 Ops/sec
bad map
92321.4 Ops/sec
Related benchmarks:
JS Test 1230
for/of vs Array loop vs foreach vs map
loop idx
JS array for test
Arary iteration comparison
loop vs map 1994
Array loop vs foreach vs map 2000
for-of-vs-map
mutate-vs-map
Comments
Confirm delete:
Do you really want to delete benchmark?