For Loop: Pre-Increment vs. Post-Increment

JavaScript performance comparison

Revision 2 of this test case created by markus

Info

Just read about it today and here's a Test-case.

http://www.fairwaytech.com/2012/03/prefix-vs-postfix-increment-and-decrement-operators-in-c/

-- Added short versions of the for-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
Pre-increment
for (var i = 0; i < 1000; ++i) {

}
pending…
Post-Increment
for (var i = 0; i < 1000; i++) {

}
pending…
+=
for (var i = 0; i < 1000; i += 1) {}
pending…
short for i--
for (var i = 1000; i--;) {}
pending…
short for --i
for (var i = 1000; --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