reduce-vs-filter-map

JavaScript performance comparison

Test case created by Samic8

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const foo = [1,2,3,4,5,6,7,8,9,10];

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
filter-map
const result = foo.filter(num => num > 3).map(num => num * 22);

console.log(result);
pending…
reduce
const result = foo.reduce((acc, num) => {
   if (num > 3) acc.push(num * 22);
   return acc;
}, []);

console.log(result);
pending…

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments