Script Preparation code:
x
 
function getRandomElement(id) {
  return {
    id,
    a: Math.random(),
    b: Math.random(),
    c: Math.random(),
  }
}
function getArray(length) {
  const result = [];
  for (let i = 0; i < length; i++) {
    result.push(getRandomElement(i))
  }
  
  return result;
}
array_small = getArray(10000);
array_large = getArray(1000000);
Tests:
  • Find small array

     
    const found = array_small.find(function(element) {
     return element.id == 9999;
    });
    found.a = 9999;
  • Map small array

     
    const array = array_small.map(function(element) {
      if (element.id == 9999) {
        element.a = 9999;
      }
      
      return element;
    });
  • Find large array

     
    const found = array_large.find(function(element) {
     return element.id == 999999;
    });
    found.a = 999999;
  • Map large array

     
    const array = array_large.map(function(element) {
      if (element.id == 999999) {
        element.a = 999999;
      }
      
      return element;
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Find small array
    Map small array
    Find large array
    Map large array

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 11 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Chrome 125 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Find small array 73252.1 Ops/sec
Map small array 33151.6 Ops/sec
Find large array 164.9 Ops/sec
Map large array 133.7 Ops/sec