mirror of
https://github.com/servo/servo.git
synced 2025-09-10 23:18:20 +01:00
Vendors the [blink perf tests](https://chromium.googlesource.com/chromium/src/+/HEAD/third_party/blink/perf_tests/). These perf tests are useful to evaluate the performance of servo. The license that governs the perf tests is included in the folder. Running benchmark cases automatically is left to future work. The update.py script is taken from mozjs and slightly adapted, so we can easily filter (and patch if this should be necessary in the future. Testing: This PR just adds the perf_tests, but does not use or modify them in any way. --------- Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
71 lines
2.2 KiB
HTML
Vendored
71 lines
2.2 KiB
HTML
Vendored
<!DOCTYPE html>
|
|
<html>
|
|
<body>
|
|
<script src="../resources/runner.js"></script>
|
|
<script>
|
|
|
|
function createDeepShadowTemplateContent(levels, slotted) {
|
|
const nestedContent = levels > 0 ? createDeepShadowTemplateContent(levels-1) : '<span>End</span>';
|
|
if (slotted) {
|
|
return `<div><template shadowrootmode=open serializable><slot></slot></template>${nestedContent}</div>`;
|
|
} else {
|
|
return `<div><template shadowrootmode=open serializable>${nestedContent}</template></div>`;
|
|
}
|
|
}
|
|
|
|
const hostChildren = 100;
|
|
|
|
// Make sure the clone operation works
|
|
function testClone(template) {
|
|
const wrapper = document.createElement('div');
|
|
document.body.appendChild(wrapper);
|
|
wrapper.appendChild(template.content.cloneNode(true));
|
|
const templateHtml = template.getHTML({serializableShadowRoots: true});
|
|
const clonedHtml = wrapper.getHTML({serializableShadowRoots: true});
|
|
if (templateHtml !== clonedHtml) {
|
|
PerfTestRunner.logFatalError('Cloned template does not match original!');
|
|
}
|
|
wrapper.remove();
|
|
}
|
|
|
|
function buildTemplate(slotted) {
|
|
const template = document.createElement('template');
|
|
document.body.appendChild(template);
|
|
const html = createDeepShadowTemplateContent(hostChildren, slotted);
|
|
template.content.setHTMLUnsafe(html);
|
|
testClone(template);
|
|
return template;
|
|
}
|
|
|
|
// Build templates once
|
|
const templateSlotted = buildTemplate(true);
|
|
const templateNested = buildTemplate(false);
|
|
|
|
if (!templateSlotted.content.firstChild.shadowRoot) {
|
|
PerfTestRunner.logFatalError("Declarative Shadow DOM must be enabled for this test.");
|
|
}
|
|
|
|
PerfTestRunner.measureRunsPerSecond({
|
|
description: "This benchmark tests cloning of templates containing declarative Shadow DOM",
|
|
|
|
setup: function() {
|
|
const wrapper = document.createElement('div');
|
|
wrapper.id = 'wrapper';
|
|
document.body.appendChild(wrapper);
|
|
},
|
|
|
|
run: function() {
|
|
const wrapper = document.querySelector('#wrapper');
|
|
for (var i = 0; i < 100; i++) {
|
|
wrapper.appendChild(templateSlotted.content.cloneNode(true));
|
|
wrapper.appendChild(templateNested.content.cloneNode(true));
|
|
}
|
|
},
|
|
|
|
teardown: function() {
|
|
wrapper.remove();
|
|
}});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|