servo/tests/blink_perf_tests/perf_tests/layout/animate-abspos-deep.html
Jonathan Schwender ee781b71b4
tests: Vendor blink perf tests (#38654)
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>
2025-08-17 09:54:04 +00:00

69 lines
1.4 KiB
HTML
Vendored

<!DOCTYPE html>
<script src="../resources/runner.js"></script>
<style>
#abs {
position: absolute;
}
.container {
position: relative;
}
</style>
<body>
<script>
window.requestAnimationFrame(function () {
setupTest();
PerfTestRunner.measureTime({
description: "Measures performance of animating a deep absolute positioned object with siblings.",
run: runTest
});
});
let abspos;
function setupTest() {
let container = document.body;
abspos = buildTree(container, 30);
appendSiblings(container, 50);
}
function runTest() {
for (let x = 0; x < 1000; x++) {
abspos.style.left = `${x}px`;
document.body.offsetTop;
}
}
// Create #abs element at the specified depth.
// <div>
// <div>
// ...
// <div class=container>
// <div id=abs></div>
// </div>
// ...
// </div>
// </div>
function buildTree(parent, depth) {
if (depth > 0) {
let child = document.createElement('div');
parent.appendChild(child);
return buildTree(child, depth - 1);
}
parent.classList.add('container');
let abspos = document.createElement('div');
abspos.id = 'abs';
abspos.appendChild(document.createTextNode('abs'));
parent.appendChild(abspos);
return abspos;
}
function appendSiblings(parent, siblings) {
for (let i = 0; i < siblings; i++) {
let child = document.createElement('div');
child.appendChild(document.createTextNode(`sibling${i}`));
parent.appendChild(child);
}
}
</script>
</body>