arrayifying_arguments (v2)

Revision 2 of this benchmark created by Irakli Gozilishvili on


Test runner

Ready to run.

Testing in
TestOps/sec
slice
function arrayify_slice() {
  var args = Array.prototype.slice.call(arguments);
  var sum = 0;
  for(var i = 0; i < 100000; i++) {
    sum += i;
  }
}

arrayify_slice(1, 2, 3, 4);
ready
manual
function arrayify_manual() {
  var len = arguments.length;
  var args = new Array(len);
  for(var i = 0; i < len; i++) {
    args[i] = arguments[i];
  }
  var sum = 0;
  for(var i = 0; i < 100000; i++) {
    sum += i;
  }
}

arrayify_manual(1, 2, 3, 4);
 
ready
concat
function arrayify_concat() {
  var args = [].concat(arguments);
  var sum = 0;
  for(var i = 0; i < 100000; i++) {
    sum += i;
  }
}

arrayify_concat(1, 2, 3, 4);
ready
push
function arrayify_push() {
  var args = [];
  args.push.apply(args, arguments);
  var sum = 0;
  for(var i = 0; i < 100000; i++) {
    sum += i;
  }
}

arrayify_push(1, 2, 3, 4);
ready
splice
function arrayify_splice() {
  var args = Array.prototype.splice.call(arguments, 0);
  var sum = 0;
  for(var i = 0; i < 100000; i++) {
    sum += i;
  }
}

arrayify_splice(1, 2, 3, 4);
ready
apply
function arrayify_apply() {
  var args = Array.apply(null, arguments);
  var sum = 0;
  for(var i = 0; i < 100000; i++) {
    sum += i;
  }
}

arrayify_apply(1, 2, 3, 4);
ready

Revisions

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

  • Revision 1: published by Malte Ubl on
  • Revision 2: published by Irakli Gozilishvili on
  • Revision 3: published by arnout on
  • Revision 4: published by Malte Ubl on
  • Revision 5: published by Irakli Gozilishvili on
  • Revision 6: published on
  • Revision 7: published on
  • Revision 8: published by mekwall on