Prefix or Postfix increment?

JavaScript performance comparison

Test case created by Christophe

Preparation code

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

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Prefix
for (var index = 0, len = data.length; index < len; ++index) {
 data[index] = data[index] * 2;
}
pending…
Suffix
for (var index = 0, len = data.length; index < len; index++) {
 data[index] = data[index] * 2;
}
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.

0 Comments