xpath evaluate vs. querySelector (v5)

Revision 5 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>

Test runner

Ready to run.

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

Revisions

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