Selectors ClassVsData && DocumentVsElement

Benchmark created by Matt R on


Description

have had multiple perfs fail to save. this one is to do something fake to verify I can even create one

Preparation HTML

<div id="div1">
<div id="innerdiv" class="divclass" data-dataselector></div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
classDocSelector
//node = document.getElementById('div1');
node = document.querySelector('.divclass');
ready
classElemSelector
outernode = document.getElementById('div1');
node = outernode.querySelector('.divclass');
ready
dataDocSelector
//node = document.getElementById('div1');
node = document.querySelector('[data-dataselector]');
ready
dataElemSelector
outernode = document.getElementById('div1');
node = outernode.querySelector('[data-dataselector]');
ready

Revisions

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