Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
tagName vs instanceof
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15
Browser:
Safari 18
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
instanceof
35781952.0 Ops/sec
tagName
56366368.0 Ops/sec
nodeName
56735744.0 Ops/sec
localName
67329712.0 Ops/sec
__proto__
31055926.0 Ops/sec
Script Preparation code:
var xs = []; var n = 0; for (let i = 0; i < 1000; ++i) { xs[i] = (Math.random() > .5) ? document.createElement(`div`) : document.createElement(`span`); };
Tests:
instanceof
n += ((xs[(Math.random() * 1000)|0]) instanceof HTMLDivElement)|0;
tagName
n += (xs[(Math.random() * 1000)|0].tagName === `DIV`)|0;
nodeName
n += (xs[(Math.random() * 1000)|0].nodeName === `DIV`)|0;
localName
n += (xs[(Math.random() * 1000)|0].localName === `div`)|0;
__proto__
n += ((xs[(Math.random() * 1000)|0]).__proto__ === HTMLDivElement.prototype)|0;