Pre or Post Increment for loop (v138)

Revision 138 of this benchmark created on


Description

http://stackoverflow.com/questions/5349425/whats-the-best-to-loop-an-array-in-javascript

Test runner

Ready to run.

Testing in
TestOps/sec
normal
var i = 0,
                                        max,
                                        myarray = [1,2,3,4,5,6,7,8,9,10];

                        for (i = 0, max = myarray.length; i < max; i += 1) {
                                // do something with myarray[i]
                        }
ready
opt for
var i, myarray = [1,2,3,4,5,6,7,8,9,10];
                        for (i = myarray.length; i--;) {
                                // do something with myarray[i]
                        }
 
ready
opt while
var myarray = [1,2,3,4,5,6,7,8,9,10],
                                        i = myarray.length;
                        while (i--) {
                                // do something with myarray[i]
                        }
ready

Revisions

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