querySelectorAll vs getElementsByTagName (v137)

Revision 137 of this benchmark created by Tri 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>

Setup

function toArray(a, b, c, d) {
        c = -1;
        d = Array(a.length);
                while ((b = a[++c])) d[c] = b
                return d;
    
    
                 }
    
    var nodes;

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
nodes = document.querySelectorAll('a')[0]
ready
getElementsByTagName
 nodes = toArray(document.getElementsByTagName('a'))[0]
ready

Revisions

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