Complex vs multiple loops

Benchmark created by bigbossSNK on


Description

Is it faster to perform many actions in one loop, or split the actions among loops?

Preparation HTML

<script>
  length = 1000
  array = []
  zero = 0
  one = 1
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Single loop
for (i = 0; i < length; i++) {
 array[i] = zero
 array[i] = one
}
ready
Multiple loops
for (i = 0; i < length; i++) {
 array[i] = zero
}
for (i = 0; i < length; i++) {
 array[i] = one
}
ready

Revisions

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

  • Revision 1: published by bigbossSNK on