Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
find faster - for vs find vs map vs foreach
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
prototype.find
3.6M/s
for
890K/s
forEach
41K/s
map
38K/s
View exact numbers
Test name
Executions per second
✓
prototype.find
3,649,330 Ops/sec
for
890,024 Ops/sec
forEach
41,114 Ops/sec
map
38,336 Ops/sec
Script Preparation code:
var arr = [] let i = 0 let len = 1000 for(;i<len;i++) { arr.push(i) }
Tests:
for
let i = 0 let len = arr.length let foundIndex = -1 for(;i<len;i++) { if (arr[i] > 999){ return i } }
prototype.find
const found = arr.find(function(element) { return element > 999 })
forEach
let foundForEachIndex = -1 arr.forEach(function (item){ if (item[i] > 999){ foundForEachIndex = i return } })
map
let foundMapIndex = arr.map(item => { if (item[i] > 999){ return i } })