Using spread operator vs builtin arguments

Benchmark created by Jelle De Loecker on


Setup

function maintest(a, b, c, d, e, f) {
      return a + b + c + d + e + f;
  }
  
  function builtin() {
      return maintest.apply(null, arguments);
  }
  
  function createArray() {
      var args = new Array(arguments.length),
          i;
  
      for (i = 0; i < arguments.length; i++) {
          args[i] = arguments[i];
      }
  
      return maintest.apply(null, arguments);
  }
  
  function useSpread(...args) {
      return maintest(...args);
  }
  
  function spreadBuiltin() {
      return maintest(...arguments);
  }

Test runner

Ready to run.

Testing in
TestOps/sec
Builtin arguments
builtin(1,2,3,4,5,6);
ready
Create array
createArray(1,2,3,4,5,6);
ready
Use spread
useSpread(1,2,3,4,5,6);
ready
Spread builtin arguments
spreadBuiltin(1,2,3,4,5,6);
ready

Revisions

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

  • Revision 1: published by Jelle De Loecker on