blob: 9f392778d7dfd90729cb0f974a8d404bafe5d953 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/runner.js"></script>
<div id="wrapper">
<div id="host"></div>
</div>
<script>
'use strict';
const numChildOfHost = 10;
const numDivsInShadow = 100;
const loops = 20;
for (let i = 0; i < numChildOfHost; ++i) {
let div = document.createElement('div');
div.appendChild(document.createTextNode('div' + i));
host.appendChild(div);
}
const slot = document.createElement('slot');
const shadowRoot = host.attachShadow({mode: 'open'});
shadowRoot.appendChild(slot);
for (let i = 0; i < numDivsInShadow; ++i) {
let div = document.createElement('div');
shadowRoot.appendChild(div);
}
function run() {
let div = document.createElement('div');
for (let i = 0; i < loops; ++i) {
host.appendChild(div);
slot.assignedNodes({flatten: true});
host.removeChild(div);
slot.assignedNodes({flatten: true});
}
}
PerfTestRunner.measureRunsPerSecond({
description: "Measure v1 distribution performance",
run: run,
done: () => {
wrapper.innerHTML = '';
}
});
</script>