Prefix increment, Postfix increment, or Add/Store? (v3)

Revision 3 of this benchmark created by Aalok Shah on


Description

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

Preparation HTML

<script>
  var len = 500 * 1000;
  var data = new Array(len);
  var index = data.length - 1;
  while (index--) data[index] = index;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Prefix
for (var index = 0; index < len; ++index) {
 data[index] = data[index] * 2;
}
ready
Suffix
for (var index = 0; index < len; index++) {
 data[index] = data[index] * 2;
}
ready
Add/Store
for (var index = 0; index < len; index+=1) {
 data[index] = data[index] * 2;
}
ready

Revisions

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