preincrement vs postincrement vs predecrement vs postdecrement

JavaScript performance comparison

Revision 4 of this test case created by max jooher

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
preincrement
var i=0, x=0;
while(++i<1000)x+=i;
pending…
postincrement
var i=0, x=0;
while(i++<999)x+=i;
pending…
predecrement
var i=1000, x=0;
while(--i)x+=i;
pending…
postdecrement
var i=999, x=0;
while(i--)x+=i;
pending…
-->0
var i=999, x=0;
while(i-->0)x+=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