jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
we discovered that calling getelementsbytagname('DIV') is a way faster than queryselectorall('DIV') http://www.nczonline.net/blog/2010/09/28/why-is-getelementsbytagname-faster-that-queryselectorall
the reason being that the former returns an HTMLCollection (live list) and the later a NodeList (static list). To go further we will see if accessing properties of a static list compensates the time to create it
========
Forked because it seems like a more fair test would just to be to change a property on 1 element rather than incurring the arbitrary cost of a loop over this particular number of elements.
<div>
<ul>
<li><a href="#">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
<li><a href="#">item 4</a></li>
<li><a href="#">item 5</a></li>
<li><a href="#">item 6</a></li>
<li><a href="#">item 7</a></li>
<li><a href="#">item 8</a></li>
<li><a href="#">item 9</a></li>
<li><a href="#">item 10</a></li>
<li><a href="#">item 11</a></li>
<li><a href="#">item 12</a></li>
<li><a href="#">item 13</a></li>
<li><a href="#">item 14</a></li>
<li><a href="#">item 15</a></li>
<li><a href="#">item 16</a></li>
<li><a href="#">item 17</a></li>
</ul>
</div>
Ready to run.
Test | Ops/sec | |
---|---|---|
querySelectorAll |
| ready |
getElementsByTagName |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.