querySelectorAll vs getElementsByTagName (v120)

Revision 120 of this benchmark created 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 nodes = document.querySelectorAll('a')
ready
getElementsByTagName
var nodes = document.getElementsByTagName('a')
ready
evaluate snapshot
var nodes = [];
var a = document.evaluate('//a', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < a.snapshotLength; i++) {
  nodes.push(a.snapshotItem(i));
}
ready
evaluate iterator
var nodes = document.evaluate('//a', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
ready

Revisions

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