for vs while (v5)

Revision 5 of this benchmark created on


Description

for vs while

Preparation HTML

<script>
  var sTexto = '',
  tmp_arr = [];
  
  for (var key = 0; key < 1000; key++) {
       tmp_arr[key] = 'a';
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
for
// async test
for (var i = 0; i < 1000; i++) {
  sTexto += tmp_arr[i]
}
ready
while (i--)
// async test
var i = 1000;
while (i--) {
  sTexto += tmp_arr[i]
}
ready
for (++i)
// async test
for (var i = 0; i < 1000; ++i) {
  sTexto += tmp_arr[i]
}
ready
for (advanced)
// async test
for (var i = 1000; i--;) {
  sTexto += tmp_arr[i]
}
ready
while (--i)
// async test
var i = 1000 + 1;
while (--i) {
  sTexto += tmp_arr[i]
}
ready
for in
// async test
for (key in tmp_arr) {
    sTexto += tmp_arr[key ]
}
  
 
ready

Revisions

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

  • Revision 1: published by antimatter15 on
  • Revision 2: published by David Calhoun on
  • Revision 3: published by Leonardo Dutra on
  • Revision 4: published by Anthony M on
  • Revision 5: published on
  • Revision 6: published on
  • Revision 7: published on
  • Revision 8: published by devu on
  • Revision 9: published by Jörn Berkefeld on
  • Revision 11: published by Milan Adamovsky on
  • Revision 18: published by Milan Adamovsky on
  • Revision 24: published by Milan Adamovsky2 on
  • Revision 30: published by Jasper on