arrayifying_arguments (v7)

Revision 7 of this benchmark created on


Preparation HTML

<script>
var ARRAY = Array.prototype;
var SLICE = ARRAY.slice;
var SPLICE = ARRAY.splice;
var PUSH = ARRAY.push;

  function applier() {
    return SLICE.call(arguments);
  }
  
  function arrayify_slice() {
    return SLICE.call(arguments);
  }
  
  function arrayify_manual() {
    var len = arguments.length;
    var args = new Array(len);
    for(var i = 0; i < len; i++) {
      args[i] = arguments[i];
    }
    return args;
  }
  
  
  function arrayify_concat() {
    var args = [].concat(arguments);
    var sum = 0;
    for(var i = 0; i < 100000; i++) {
      sum += i;
    }
    return args;
  }
  
  function arrayify_push() {
    var args = [];
    PUSH.apply(args, arguments);
    return args;
  }
  
  function arrayify_splice() {
    var args = SPLICE.call(arguments, 0);
    return args;
  }
  
  function arrayify_apply() {
    var args = arguments.length === 1 ? [ arguments[0] ] : Array.apply(null, arguments);
    return args;
  }
  
  function arrayify_function() {
    var args = applier.apply(null, arguments);
    return args;
  }
  
  function arrayify_slice_apply() {
    var args = SLICE.apply(arguments);
    return args;
  }
  
  
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
slice
arrayify_slice(1, 2, 3, 4);
ready
manual
arrayify_manual(1, 2, 3, 4);
 
ready
concat
arrayify_concat(1, 2, 3, 4);
ready
push
arrayify_push(1, 2, 3, 4);
ready
splice
arrayify_splice(1, 2, 3, 4);
ready
apply
arrayify_apply(1, 2, 3, 4);
ready
special_function
arrayify_function(1, 2, 3, 4);
ready
slice_apply
arrayify_slice_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