For loop: i++ vs. ++i vs. i+=1 (v3)

Revision 3 of this benchmark created by Jesse on


Preparation HTML

<script>
  var l = 100000000;
  
  function doNothing() {}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Post-Increment
for (var i = 0; i < l; i++) {
  doNothing();
}
ready
Pre-Increment
for (var i = 0; i < l; ++i) {
  doNothing();
}
ready
Crockford's Delight
for (var i = 0; i < l; i += 1) {
  doNothing();
}
ready

Revisions

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