Script Preparation code:
x
 
var arr = [];
for (var i = 0; i < 1000; i++) {
  arr[i] = i;
}
function someFn(i) {
  return (i * 3 * 8 / 1200 * 0.002 / 40 * 0.2);
}
var sumForEach = 0,
  sumReduce = 0,
  sumMap = 0,
  sumFilter = 0,
  sumFor = 0;
Tests:
  • filter

     
    arr.filter(item => (sumFilter += someFn(item)));
  • reduce

     
    sumReduce = arr.reduce((lastValue, item) => {
      return sumReduce += someFn(item);
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    filter
    reduce

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Linux; Android 10; SM-G965F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Mobile Safari/537.36
Chrome Mobile 106 on Android
View result in a separate tab
Test name Executions per second
filter 1393.1 Ops/sec
reduce 1438.6 Ops/sec