Script Preparation code:
AخA
 
var arr = [1,2,3,4,5,6,7,8,9,0], farr;
Tests:
  • Filter

     
    farr = arr.filter(function(item) { 
      return (item>4); 
    });
  • For

     
    for (var i=0,len=arr.length;i<len;i++) {
      if (arr[i]<5) continue;
      farr.push(arr[i]);
    }
  • For 2

     
    for (var i=0,len=arr.length;i<len;i++) {
      if (arr[i]>4) farr.push(arr[i]);
    }
  • For in

     
    for (var i in arr) {
      if (arr[i]>4) farr.push(arr[i]);
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Filter
    For
    For 2
    For in

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 18 days ago)
Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0
Firefox 136 on Linux
View result in a separate tab
Test name Executions per second
Filter 10658021.0 Ops/sec
For 2886177.0 Ops/sec
For 2 2162296.8 Ops/sec
For in 630407.8 Ops/sec