gist3091932

JavaScript performance comparison

Test case created by Josh

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var my_array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
   
       
    function myMethod() {
      return my_array.length
    }
};
</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
fast
var l1 = my_array.length
for (var i = 0; i < l1; i++) {}
var l2 = myMethod()
for (var i = 0; i < l2; i++) {}
pending…
slow
for (var i = 0; i < my_array.length; i++) {}
for (var i = 0; i < myMethod(); i++) {}
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