Args copying (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script>
  function f() {
    return Array.prototype.slice.call(arguments, 0);
  }
  
  function g() {
    var length = arguments.length;
    var args = new Array(length);
    var i = length;
    while (i-- > 0) {
      args[i] = arguments[i];
    }
    return args;
  }
  
  function h() {
    var length = arguments.length;
    var args = new Array(length);
    for (var i = 0; i < length; ++i) {
      args[i] = arguments[i];
    }
    return args;
  }
  
  function i() {
    return [].concat(arguments);
  }
  
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Slice
f();
f(1);
f(1, 2);
f(1, 2, 3);
f(1, 2, 3, 4);
f(1, 2, 3, 4, 5);
ready
While loop
g();
g(1);
g(1, 2);
g(1, 2, 3);
g(1, 2, 3, 4);
g(1, 2, 3, 4, 5);
ready
For loop
h();
h(1);
h(1, 2);
h(1, 2, 3);
h(1, 2, 3, 4);
h(1, 2, 3, 4, 5);
ready
Concat
i();
i(1);
i(1, 2);
i(1, 2, 3);
i(1, 2, 3, 4);
i(1, 2, 3, 4, 5);
ready

Revisions

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