instanceof performance (v16)

Revision 16 of this benchmark created on


Setup

function Test()
    {
    this.property = true;
    }
    
    function Test2()
    {
    }
    
    var arr = [], ts2 = [];
    var result;
    for(var i = 0; i < 1000; i++) {
    arr.push(new Test());
        ts2.push(new Test2());
    }

Test runner

Ready to run.

Testing in
TestOps/sec
instanceof success
for(var i = 0; i < 1000; ++i)
{
var t = arr[i];
result = t instanceof Test;
}
ready
property success
for(var i = 0; i < 1000; ++i)
{
var t = arr[i];
result = t.property;
}
ready
instanceof fail
for(var i = 0; i < 1000; ++i)
{
var t = ts2[i];
result = t instanceof Test;
}
ready
property fail
for(var i = 0; i < 1000; ++i)
{
var t = ts2[i];
result = t.property;
}
ready
constructor success
for(var i = 0; i < 1000; ++i)
{
var t = arr[i];
result = t.constructor === Test;
}
ready
constructor fail
for(var i = 0; i < 1000; ++i)
{
var t = ts2[i];
result = t.constructor === Test;
}
ready

Revisions

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