++i++

JavaScript performance comparison

Revision 2 of this test case created

Info

Testing ++i vs i++ in a loop.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = [];
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
i++ low n
for(var i = 0; i < 100; i++) {
  a.push(i);
}
pending…
++i low n
for(var i = 0; i < 100; ++i) {
  a.push(i);
}
pending…
i++ medium n
for(var i = 0; i < 1000; i++) {
  a.push(i);
}
pending…
++i medium n
for(var i = 0; i < 1000; ++i) {
  a.push(i);
}
pending…
i++ large n
for(var i = 0; i < 10000; i++) {
  a.push(i);
}
pending…
++i large n
for(var i = 0; i < 10000; ++i) {
  a.push(i);
}
pending…
i+=1 low n
for(var i = 0; i < 100; i+=1) {
  a.push(i);
}
pending…
i+=1 medium n
for(var i = 0; i < 1000; i+=1) {
  a.push(i);
}
pending…
i+=1 large n
for(var i = 0; i < 10000; i+=1) {
  a.push(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