servo/tests/blink_perf_tests/perf_tests/layout/css-contain-change-text.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

70 lines
1.6 KiB
HTML
Vendored

<!DOCTYPE html>
<style>
div {
position: relative;
height: 3000px;
}
.cell {
position: absolute;
border: solid;
width: 60px;
height: 30px;
box-sizing: border-box;
contain: size layout;
line-height: 1;
}
div:nth-child(2n) {
text-align: center;
}
div:nth-child(3n) {
text-align: end;
}
</style>
<script src="../resources/runner.js"></script>
<script>
let textNodes = [];
function populateData() {
let container = document.createElement('div');
let top = 0;
for (let i = 0; i < 100; i++) {
let left = 0;
for (let j = 0; j < 100; j++) {
let cell = document.createElement('div');
cell.classList.add('cell');
let textNode = document.createTextNode('' + (100 * Math.random()).toFixed(2));
cell.appendChild(textNode);
cell.style.left = left + "px";
cell.style.top = top + "px";
container.appendChild(cell);
textNodes.push(textNode);
left += 60;
}
top += 30;
}
document.body.appendChild(container);
}
function startTest() {
populateData();
PerfTestRunner.forceLayout();
PerfTestRunner.measureTime({
description: "Measures performance of changing text nodes content.",
run: function() {
for (let i = 0; i < textNodes.length; i++) {
textNodes[i].data = '' + (100 * Math.random()).toFixed(2);
}
PerfTestRunner.forceLayout();
},
});
}
</script>
<body onload="startTest();">
</body>