Prefix or Postfix increment? (v40)

Revision 40 of this benchmark created by Maciej Bukowski 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 data = new Array(500 * 1000);
  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 < data.length; index++) {
  data[index]++;
  data[index]++;
  data[index]++;
  data[index]++;
  data[index]++;
  data[index]++;
  data[index]++;
  data[index]++;
  data[index]++;
  data[index]++;
}
ready
Suffix
for (var index = 0; index < data.length; index++) {
  ++data[index];
  ++data[index];
  ++data[index];
  ++data[index];
  ++data[index];
  ++data[index];
  ++data[index];
  ++data[index];
  ++data[index];
  ++data[index];
}
ready

Revisions

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