Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
querySelectorAll vs query
(version: 0)
100 Li elements using querySelectorAll and custom query function got from http://ryanmorr.com/abstract-away-the-performance-faults-of-queryselectorall/
Comparing performance of:
query vs querySelectorAll vs getElementByTagName
Created:
8 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<html> <body> <ul style="list-style: none outside none;"> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 2</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 3</li> <li style="float: left;display: block;width: 100px;height: 40px;">Field 1</li> </ul> </body> </html>
Script Preparation code:
function query(selector, context) { context = context || document; // Redirect simple selectors to the more performant function if (/^(#?[\w-]+|\.[\w-.]+)$/.test(selector)) { switch (selector.charAt(0)) { case '#': // Handle ID-based selectors return [context.getElementById(selector.substr(1))]; case '.': // Handle class-based selectors // Query by multiple classes by converting the selector // string into single spaced class names var classes = selector.substr(1).replace(/\./g, ' '); return [].slice.call(context.getElementsByClassName(classes)); default: // Handle tag-based selectors return [].slice.call(context.getElementsByTagName(selector)); } } // Default to `querySelectorAll` return [].slice.call(context.querySelectorAll(selector)); }
Tests:
query
query("li", document)
querySelectorAll
document.querySelectorAll("li")
getElementByTagName
document.getElementsByTagName("li")
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
query
querySelectorAll
getElementByTagName
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It seems like you're describing a benchmarking scenario, likely for web performance or rendering speed. Given the information, I'll try to provide an answer based on the provided data: **Individual Test Cases:** 1. **query**: This test case is expecting the browser to execute a query on an HTML document using the `document.querySelector` method. 2. **querySelectorAll**: This test case is expecting the browser to use the `document.querySelectorAll` method to select all elements with the tag name "li". 3. **getElementByTagName**: This test case is expecting the browser to use the `document.getElementsByTagName` method to get a list of all elements with the tag name "li". **Latest Benchmark Result:** The benchmark results show that: * Chrome 62 performs the best in the `getElementByTagName` test, with an average execution speed of ~3511095.5 executions per second. * Chrome 62 also performs well in the `querySelectorAll` test, with an average execution speed of ~43677.3671875 executions per second. * The `query` test case has a lower performance compared to the other two tests, with an average execution speed of ~38378.95703125 executions per second. Based on these results, it seems that Chrome 62 is performing well in all three test cases. However, without more information about the HTML document being queried or the specific elements being targeted, it's difficult to provide a more detailed analysis. If you have any additional context or details, I'd be happy to try and help further!
Related benchmarks:
querySelector() vs getElementsByClassName()[0]
getElementsByClassName()[0] vs querySelectorAll
speed test query selector vs classname1
Performance of query selector vs className
querySelector(class) vs classList.some
Comments
Confirm delete:
Do you really want to delete benchmark?