getElementById vs. querySelector (v291)

Revision 291 of this benchmark created on


Preparation HTML

<root xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
   <employees>
	<actors>
		<actor id="1">Christian Bale</actor>
		<actor id="2">Liam Neeson</actor>
		<actor id="3">Michael Caine</actor>
	</actors>
	<foo:singers>
		<foo:singer id="4">Tom Waits</foo:singer>
		<foo:singer id="5">B.B. King</foo:singer>
		<foo:singer id="6">Ray Charles</foo:singer>
	</foo:singers>
   </employees>
   <tools>
	<knives>
		<Knive id="1">
			<color>red</color>
			<color>blue</color>
		</Knive >
	</knives>
   </tools>
</root>

Test runner

Ready to run.

Testing in
TestOps/sec
XPath
var bar = document.evaluate("//foo:singer[@id='5']", document, null, 9, null).singleNodeValue;
ready
getElementById
var bar = document.getElementById("5");
ready

Revisions

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