instanceof performance (v10)

Revision 10 of this benchmark created on


Setup

function Test()
    {
    this.type = "crap";
    }
    
    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.type === 'crap';
}
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.type === "lame";
}
ready

Revisions

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