i++ vs ++i, with and without caching (v111)

Revision 111 of this benchmark created by Max Marshall on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script>
  var a = $('*').get(),
      e;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
i++ without caching
for (var i = 0; i < a.length; i++) { e = a[i]; }
ready
++i without caching
for (var i = 0;; i < a.length; ++i) { e = a[i]; }
ready
i++ with caching
for (var i = 0, len = a.length; i < len; i++) { e = a[i]; }
ready
++i with caching
for (var i = 0, len = a.length; i < len; i++) { e = a[i]; }
ready

Revisions

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