xpath evaluate vs. querySelector (v22)

Revision 22 of this benchmark created on


Description

Compare the speed of xpath evaluate to querySelector

Preparation HTML

<p id="foo">Foo</p>
<p id="bar">Bar</p>
<p id="baz">Baz</p>
<div id="toto"><div><p><span>yoyo</span></p></div></div>

Test runner

Ready to run.

Testing in
TestOps/sec
xpath evaluate
var bar = document.evaluate("//*[@id='toto']/div/p/span",document,null,9,null).singleNodeValue;
ready
querySelector
var bar = document.querySelector("#toto > div > p > span");
ready
xpath evaluate (firefox id function)
var bar = document.evaluate("id('toto')/div/p/span",document,null,9,null).singleNodeValue;
ready
querySelector descendant
var bar = document.querySelector("#toto span");
ready

Revisions

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