document.contains vs element.getRootNode() (v3)

Revision 3 of this benchmark created on


Preparation HTML

<div id="host"></div>

Setup

const N = 100;
let node = document.getElementById("host");
for (let i = 0; i < N; i++) {
	const el = document.createElement('div');
	node.appendChild(el);
	node = el;
}

Test runner

Ready to run.

Testing in
TestOps/sec
document.contains
document.contains(node);
ready
getRootNode({composed: true})
node.getRootNode({composed: true});
ready
getRootNode()
node.getRootNode();
ready

Revisions

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