inline loop test

JavaScript performance comparison

Test case created

Info

Test difference between local caching of loop stop condition or not

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var anObject = {
    array: []
    };
   
    for(var i=0, countI=1000;i<countI;i++) {
    anObject.array.push(i);
    }
};
</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
Local caching of length
var countI = anObject.array.length;
var total = 0;
for(var i=0;i<countI;i++) {
total+=i;
}
pending…
no caching of length
var total = 0;
for(var i=0;i<anObject.array.length;i++) {
total+=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