Increment decrement for loop

JavaScript performance comparison

Revision 2 of this test case created

Info

Which is faster, increment or decrement for loop

Preparation code

<ul class="list">

</ul>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var list = $('.list');
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
increment for loop
var i=0;
var sum=0;
var temp = null;
for (; i < 1000; i++) {
   //sum +=i;
   temp = "";
}
pending…
decrement for loop
var i=1000;
var sum=0;
var temp = null;
while(i>0) {
   //sum +=i;
   temp = "";
    --i;
}
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