arguments-woes (v2)

Revision 2 of this benchmark created on


Description

Separately test the 2 changes made in joyent/node@91f1b250ecb4fb8151cd17423dd4460652d0ce97

Preparation HTML

<script>
  function f() {
    var args = Array.prototype.slice.call(arguments, 1);
    return args;
  }
  
  function ff(type) {
    var args = Array.prototype.slice.call(arguments, 1);
    return args;
  }
  
  function g() {
    var l = arguments.length;      
    var args = new Array(l - 1);
    for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
    return args;
  }
  
  function gg(type) {
    var l = arguments.length;      
    var args = new Array(l - 1);
    for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
    return args;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Argument.prototype.slice
f(1); f(1, 2); f(1, 2, 3);
ready
loop through arguments and copy to args
g(1); g(1, 2); g(1, 2, 3);
ready
Argument.prototype.slice with named argument
ff(1); ff(1, 2); ff(1, 2, 3);
ready
loop through arguments and copy to args with named argument
gg(1); gg(1, 2); gg(1, 2, 3);
ready

Revisions

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