Script Preparation code:
AخA
 
var arr = []
let i = 0
let len = 1000
for(;i<len;i++) {
    arr.push(i)                
}
Tests:
  • for

    x
     
    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
        }
    })
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for
    prototype.find
    forEach
    map

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 11 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Chrome 135 on Windows
View result in a separate tab
Test name Executions per second
for 979191.9 Ops/sec
prototype.find 4385400.5 Ops/sec
forEach 37010.4 Ops/sec
map 35551.6 Ops/sec