Simple Loop Optimizations

Benchmark created by Jasper on


Preparation HTML

<script>

var catPictures = [];
var len = 1000;
while(len--){
    catPictures.push({});
}

</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Uncached for loop
for (var i = 0; i < catPictures.length; i++)
        catPictures[ i ].comment = 'lolz';
ready
Cached length
for (var i = 0, l = catPictures.length; i < l; i++)
        catPictures[ i ].comment = 'lolz';
ready

Revisions

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