Loops (v105)

Revision 105 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)
{
var test = a[i] * i;
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
for reverse loop
for (var i = a.length - 1; i >= 0; --i)
{
var test = a[i] * i;
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
for inc inline
for(var i = -1, n = a.length; ++i < n;)
{
var test = a[i] * i;
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
for reverse dec inline
for (var i = a.length; --i >= 0;)
{
var test = a[i] * i;
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
while reverse
var i = a.length - 1;
while (i > -1)
{
var test = a[i] * i;
    if (typeof(a[i]) === "undefined")
        throw "error";
    --i;
}
ready
while reverse dec inline
var i = a.length;
while(i-- > 0)
{
var test = a[i] * i;
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
while reverse dec inline implicit
var i = a.length;
while(i--)
{
var test = a[i] * i;
    if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
for inside
for(var i in a){
var test = a[i] * i;
        if (typeof(a[i]) === "undefined")
        throw "error";
}
ready
for outside
var i = null;
for(i in a){
var test = a[i] * i;
        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.