reduce for

Benchmark created by 辛文韬 on


Preparation HTML

<script>
var a = [];
for(var i = 0; i < 1000000; i++) {
	a.push(i);
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
for from 0 to max
var total = 0;
for (var i = 0, len = a.length; i < len; i++)
{
  total += a[i];
}
ready
for from max to 0
var total = 0;
for (var i = a.length; i > -1; i--)
{
  total += a[i];
}
ready
for use arr.length
var total = 0;
for (var i = 0; i < a.length; i++)
{
  total += a[i];
}
ready

Revisions

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

  • Revision 1: published by 辛文韬 on