mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02: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
1.4 KiB
HTML
71 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../resources/runner.js"></script>
|
|
<script src="./resources/utils.js"></script>
|
|
<style id=style></style>
|
|
<div id=root></div>
|
|
<script>
|
|
const SELECTORS = 1000;
|
|
const DOM_WIDTH = 10;
|
|
const DOM_DEPTH = 1000;
|
|
|
|
function makeStyle() {
|
|
let selectors = [...Array(SELECTORS).keys()].map(x => `.a${x}`);
|
|
// Creates a selector list which is expensive to evaluate:
|
|
// (.a1, .a2, .a3 ... .a<n-1>, ...)
|
|
return `
|
|
@scope (:not(:is(${selectors.join(',')})).foo) {
|
|
div:empty:not(.bar) {
|
|
margin: 1px;
|
|
}
|
|
}
|
|
`;
|
|
}
|
|
|
|
function makeChain(n) {
|
|
if (n <= 0) {
|
|
return null;
|
|
}
|
|
let element = document.createElement('div');
|
|
let child = makeChain(n - 1);
|
|
if (child != null) {
|
|
element.appendChild(child);
|
|
}
|
|
return element;
|
|
}
|
|
|
|
let leaf_nodes = [];
|
|
|
|
function setup() {
|
|
style.textContent = makeStyle();
|
|
|
|
for (let i = 0; i < DOM_WIDTH; ++i) {
|
|
root.appendChild(makeChain(DOM_DEPTH));
|
|
}
|
|
|
|
leaf_nodes = document.querySelectorAll('div:empty');
|
|
}
|
|
|
|
setup();
|
|
|
|
PerfTestRunner.measureTime({
|
|
description: 'Non-matching ancestor via :scope',
|
|
run: () => {
|
|
root.offsetTop;
|
|
for (let e of leaf_nodes) {
|
|
e.classList.toggle('bar');
|
|
}
|
|
root.offsetTop;
|
|
for (let e of leaf_nodes) {
|
|
e.classList.toggle('bar');
|
|
}
|
|
root.offsetTop;
|
|
for (let e of leaf_nodes) {
|
|
e.classList.toggle('bar');
|
|
}
|
|
root.offsetTop;
|
|
}
|
|
});
|
|
|
|
</script>
|
|
|