i++ vs ++i vs i+=1 (v5)

Revision 5 of this benchmark created by Joshua Scott on


Description

Test to see which is fastest, i++, ++i, or i+=1 in a for loop

Test runner

Ready to run.

Testing in
TestOps/sec
100000 iterations of ++i
for (var x = 0, i = 0; i < 100000; ++i) { x = i; }
ready
100000 iterations of i++
for (var x = 0, i = 0; i < 100000; i++) { x = i; }
ready
100000 iterations of i+=1
for (var x = 0, i = 0; i < 100000; i+=1) { x = i; }
ready

Revisions

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