instanceof performance /w length (v5)

Revision 5 of this benchmark created on


Setup

function Test() {
      this.type = 'Test';
    }
    
    function Test2() {
      this.type = 'Test2';
    }
    var arr = [],
        arr2 = [];
    var result;
    for (var i = 0; i < 1000; i++) {
      arr.push(new Test());
      arr2.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 === 'Test';
}
ready
instanceof fail
for (var i = 0; i < 1000; ++i) {
  var t = arr2[i];
  result = t instanceof Test;
}
ready
property fail
for (var i = 0; i < 1000; ++i) {
  var t = arr2[i];
  result = t.type === 'Test';
}
ready

Revisions

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