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 (Macintosh; Intel Mac OS X 10.15; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
instanceof
23.2M/s
nodeType literal
23.1M/s
nodeType
20.5M/s
View exact numbers
Test name
Executions per second
✓
instanceof
23,168,934 Ops/sec
nodeType literal
23,052,840 Ops/sec
nodeType
20,494,020 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;