trnbdtybfg

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var slice = [].slice;
   
    function f1(arr) {
      return slice.call(arr)
    }
   
    function f2(arr) {
      var obj=Object(arr),
          len = obj.length>>>0,
          rez= Array(len);
      while (len--)if(len in obj)rez[len] = obj[len];
      return rez
    }
    function f3(arr) {
      var len = arr!=null?arr.length>>>0:0,
          rez= Array(len);
      while (len--)if(len in arr)rez[len] = arr[len];
      return rez
    }
};
</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
f1 x 2
f1(function(){return arguments}(1, 2))
pending…
f2 x 2
f2(function(){return arguments}(1, 2))
pending…
f1 x 20
f1(function(){return arguments}(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 90))
pending…
f2 x 20
f2(function(){return arguments}(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 90))
pending…
f3 x 2
f3(function(){return arguments}(1, 2))
pending…
f3 x 20
f3(function(){return arguments}(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 90))
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment