args

JavaScript performance comparison

Test case created by Stoyan

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function stuffFive(a, b, c, d, e) {
      var copy = [];
      var args = [a, b, c, d, e];
      var i = 0;
      var v;
      while (args[i]) {
        copy[i] = args[i];
        i++;
      }
      return copy;
    }
   
    function stuffWhatever() {
      var copy = [];
      var args = arguments;
      var i = 0;
      var v;
      while (args[i]) {
        copy[i] = args[i];
        i++;
      }
      return copy;
    }
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
5 : 1
stuffFive(1);
pending…
args: 1
stuffWhatever(1);
pending…
5: 2
stuffFive(1, 2);
pending…
args: 2
stuffWhatever(1, 2);
pending…
5: 5
stuffFive(1,2,3,4,5);
pending…
args: 5
stuffWhatever(1,2,3,4,5);
pending…

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

Compare results of other browsers

0 comments

Add a comment