Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
nodeType vs instanceof
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/126.0.6478.35 Mobile/15E148 Safari/604.1
Browser:
Chrome Mobile iOS 126
Operating system:
iOS 17.5
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
nodeType
5706697.0 Ops/sec
instanceof
5758213.5 Ops/sec
nodeType literal
7950768.5 Ops/sec
Script Preparation code:
var xs = []; var n = 0; for (let i = 0; i < 1000; ++i) { xs[i] = (Math.random() > .5) ? document.createElement(`a`) : document.createTextNode(``); };
Tests:
nodeType
n += (xs[(Math.random() * 1000)|0].nodeType === Node.ELEMENT_NODE)|0;
instanceof
n += ((xs[(Math.random() * 1000)|0]) instanceof HTMLElement)|0;
nodeType literal
n += (xs[(Math.random() * 1000)|0].nodeType === 1)|0;