for -for

Benchmark created by 辛文韬 on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
for use len
var total = 0;
for (var i = 0, len = a.length; i < len; i++)
{
  total += a[i];
}
ready
for use a.length
var total = 0;
for (var i = 0; i < a.length; i++)
{
  total += a[i];
}
ready
for reverse
var total = 0;
for (var i = a.length - 1; i > -1; 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