replace-in-fragmentdocument-clone

Benchmark created by 3po on


Setup

var f = document.createDocumentFragment();
    f.appendChild(document.createElement('div'));
    f.appendChild(document.createElement('div'));
    f.appendChild(document.createElement('div'));
    f.appendChild(document.createElement('div'));
    var d = document.createElement('div');
    d.appendChild(document.createElement('div'));
    d.appendChild(document.createElement('div'));
    d.appendChild(document.createElement('div'));
    d.appendChild(document.createElement('div'));
    var d2 = document.createElement('div');
    d2.appendChild(document.createElement('div'));
    d2.appendChild(document.createElement('div'));
    var d3 = document.createElement('div');
    d3.setAttribute('id', 'test');
    d2.appendChild(d3);
    d2.appendChild(document.createElement('div'));
    d2.appendChild(document.createElement('div'));
    d.appendChild(d2);
    d.appendChild(document.createElement('div'));
    d.appendChild(document.createElement('div'));
    d.appendChild(document.createElement('div'));
    d.appendChild(document.createElement('div'));
    f.appendChild(d);
    f.appendChild(document.createElement('div'));
    f.appendChild(document.createElement('div'));
    f.appendChild(document.createElement('div'));
    f.appendChild(document.createElement('div'));

Test runner

Ready to run.

Testing in
TestOps/sec
query selector

var clone = f.cloneNode(true);
var test = clone.querySelector('#test');
var parent = test.parentNode;
parent.replaceChild(document.createElement('span'), test);
 
ready
childnodes

var clone = f.cloneNode(true);
var parent = clone.childNodes[4].childNodes[4]
var test = parent.childNodes[2];
parent.replaceChild(document.createElement('span'), test);
ready

Revisions

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