querySelectorAll vs getElementsByTagName (v65)

Revision 65 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
var i, item, count, nodes = document.querySelectorAll('[data-2x]');

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.getAttribute('data-2x')) count++;

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.