Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
TreeWalker vs querySelectorAll vs NodeIterator filters
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 133
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
TreeWalker
559347.1 Ops/sec
querySelectorAll
809522.0 Ops/sec
NodeIterator
410099.9 Ops/sec
HTML Preparation code:
<!-- article out start --> <article> <!-- article in start --> <h1>Lorem ipsum</h1> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque, nostrum.</p> <!-- article in end --> </article> <!-- article out end --> <!-- article out start --> <article> <!-- article in start --> <h1>Lorem ipsum</h1> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque, nostrum.</p> <!-- article in end --> </article> <!-- article out end --> <!-- article out start --> <article> <!-- article in start --> <h1>Lorem ipsum</h1> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque, nostrum.</p> <!-- article in end --> </article> <!-- article out end -->
Tests:
TreeWalker
const walker = document.createTreeWalker( document.body, NodeFilter.SHOW_ELEMENT, ); for (let node = walker.nextNode(), i = 0; node; i++, node= walker.nextNode() ) { if(node.nodeName == 'H1') node.className = 'classy' ; }
querySelectorAll
const elements = Array.from(document.body.querySelectorAll('h1')) for(let i = 0, len = elements.length; i < len; i++){elements[i].className = 'classy'}
NodeIterator
const walker = document.createNodeIterator( document.body, NodeFilter.SHOW_ELEMENT, ); for (let node = walker.nextNode(), i = 0; node; i++, node= walker.nextNode() ) { node.className = 'classy' ; }