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 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0
Browser:
Firefox 143
Operating system:
Windows
Device Platform:
Desktop
Date tested:
10 months ago
nodeType literal
33.1M/s
nodeType
32.6M/s
instanceof
22.8M/s
View exact numbers
Test name
Executions per second
✓
nodeType literal
33,133,704 Ops/sec
nodeType
32,578,570 Ops/sec
instanceof
22,807,962 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;