querySelectorAll vs getElementById (v46)

Revision 46 of this benchmark created on


Preparation HTML

<span data-l10n-id="foo0">gix</span>
<span data-l10n-id="foo1">gix</span>
<span data-l10n-id="foo2">gix</span>
<span data-l10n-id="foo3">gix</span>
<span data-l10n-id="foo4">gix</span>
<span data-l10n-id="foo5">gix</span>
<span data-l10n-id="foo6">gix</span>
<span data-l10n-id="foo7">gix</span>
<span data-l10n-id="foo8">gix</span>
<span data-l10n-id="foo9">gix</span>
<p id="foo">bar</p>

Test runner

Ready to run.

Testing in
TestOps/sec
querySelectorAll
var nodes = document.querySelectorAll('[data-l10n-id]');
for (var i = 0; i < nodes.length; i++) {
  var node = nodes[i];
}
ready
querySelector
for (var i = 0; i < 10; i++) {
  var node = document.querySelector('[data-l10n-id=foo' + i + ']');
}
ready

Revisions

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