Test Using ++ or += in a loop

JavaScript performance comparison

Test case created by James Wilkins and last updated

Info

Determine if ++ or += makes any difference in a loop.

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Test post ++
for (var i = 0; i < 1000000; i++);
pending…
Test +=
for (var i = 0; i < 1000000; i += 1);
pending…
Test pre ++
for (var i = 0; i < 1000000; ++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:

1 comment

James Wilkins (revision owner) commented :

I guess in summary, it looks like pre ++ (i.e. ++i) is the consistently faster operation across most common browsers - though I'm a little shocked, however, that Chrome is so bad. :( Makes me wonder if chrome is being forced to re-compile and execute the code each time (since it JIT compiles to machine code).

Add a comment