Prefix or Postfix increment? (v31)

Revision 31 of this benchmark created on


Description

So with recent JS runtimes, does using the prefix increment/decrement operators squeeze the usual performance droplet from loop index maintenance?

Setup

var x = 0;

Teardown


    console.log(x);
  

Test runner

Ready to run.

Testing in
TestOps/sec
Prefix
for (var i = 0; i < 1000; ++i) {
 ++x;
}
ready
Suffix
for (var i = 0; i < 1000; i++) {
 x++;
}
 
ready
Plus 1
for (var i = 0; i < 1000; i += 1) {
 x += 1;
}
ready

Revisions

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