Loops (v104)

Revision 104 of this benchmark created on


Setup

var a = new Array(100);
    var len = a.length;
    
    for(var i=-1;++i<len;) a[i]=i;
    var z = 99;

Test runner

Ready to run.

Testing in
TestOps/sec
for loop
for (var i = 0, n = a.length; i < n; ++i)
{
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
for reverse loop
for (var i = a.length - 1; i >= 0; --i)
{
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
for inc inline
for(var i = -1, n = a.length; ++i < n;)
{
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
for reverse dec inline
for (var i = a.length; --i >= 0;)
{
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
while reverse
var i = a.length - 1;
while (i > -1)
{
    if (typeof(a[i]) === "undefined")
        throw "error";
    --i;
}
ready
while reverse dec inline
var i = a.length;
while(i-- > 0)
{
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
while reverse dec inline implicit
var i = a.length;
while(i--)
{
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
total baseline
for(i=0;false;){
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready

Revisions

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