Script Preparation code:
AخA
 
var arr = new Array({ length: 10000 }, () => Math.floor(Math.random() * 1000));
Tests:
  • Array_filter_method

     
    var isGreaterThan500 = val => val > 500;
    var filtered = arr.filter(isGreaterThan500)
  • classic_for_loop_filter

    x
     
    var l = arr.length
    var filtered = [];
    for (var i = 0; i < l; i++) {
      var val = arr[i];
      if (val > 500) {
        filtered.push(val);
      }
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array_filter_method
    classic_for_loop_filter

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 6 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Array_filter_method 5464414.5 Ops/sec
classic_for_loop_filter 3971685.0 Ops/sec