querySelectorAll vs getElementsByTagName (v61)

Revision 61 of this benchmark created by Oliver Clevont on


Preparation HTML

<div>
  <ul>
    <li><a href="#">item 1</a></li>
    <li><a href="#">item 2</a></li>
    <li><a href="#">item 3</a></li>
  </ul>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
var i, item, count, nodes = document.querySelectorAll('a');

for(i=0; item = nodes[i++];) if(item.tagName) count++;
ready
getElementsByTagName
var i, item, count, nodes = document.getElementsByTagName('a');

for(i=0; item = nodes[i++];) if(item.tagName) count++;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.