Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
foreach vs map by wayne
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
foreach
5K/s
map
4K/s
View exact numbers
Test name
Executions per second
✓
foreach
5,254 Ops/sec
map
4,219 Ops/sec
Tests:
foreach
let arr = Array(10000); arr.fill({name: 'ddd', age: 123}); const newArr1 = [] const newArr2 = [] arr.forEach((v) => { newArr1.push(v.name) newArr2.push(v.age) })
map
let arr = Array(10000); arr.fill({name: 'ddd', age: 123}); const newArr2 = [] const newArr1 = arr.map((v) => { newArr2.push(v.age) return v.name })