for-vs-while--

Benchmark created on


Setup

var array = (new Array(1e5 + 1)).join(1).split('');

Test runner

Ready to run.

Testing in
TestOps/sec
while--
var i = array.length;
while (i--) {
  var a = array[i];
}
ready
for++
var length = array.length;
for (var i = 0; i < length; ++i) {
  var a = array[i];
}
ready
for++ array.length
for (var i = 0; i < array.length; ++i) {
  var a = array[i];
}
ready
for--
for (var i = array.length; i; i--) {
  var a = array[i];
}
ready
for i++
var length = array.length;
for (var i = 0; i < length; i++) {
  var a = array[i];
}
ready

Revisions

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

  • Revision 1: published on
  • Revision 2: published by Heavensrevenge on