Script Preparation code:
AخA
 
var array = [];
for (let i = 0 ; i < 10000 ; i++) {
    array.push ({ value: Math.floor (Math.random () * 1000) });
}
Tests:
  • reversed for loop

     
    const value = Math.floor (Math.random () * 1000);
    let found = undefined;
    for (let i =  array.length - 1 ; i >= 0 ; i--) {
        const cell =  array[i];
        if (cell.value === value) {
            found = cell;
            break;
        }
    }
  • find method =>

     
    const value = Math.floor (Math.random () * 1000);
    let found = array.find ((cell) => cell.value === value);
  • find method function

     
    const value = Math.floor (Math.random () * 1000);
    let found = array.find (function (cell) { return cell.value === value });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    reversed for loop
    find method =>
    find method function

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131 on Windows
View result in a separate tab
Test name Executions per second
reversed for loop 469430.2 Ops/sec
find method => 860505.5 Ops/sec
find method function 855161.8 Ops/sec