servo/tests/blink_perf_tests/perf_tests/layout/abspos.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

76 lines
1.9 KiB
HTML
Vendored

<!DOCTYPE html>
<style>
.row {
position: relative;
font-size: 10px;
}
.cell {
position: absolute;
height: 10px;
width: 50px;
}
</style>
<div id="wrapper">
</div>
<pre id="log" style="position: absolute; left: 300px;"></pre>
<template id="row-template">
<div class="row">
<div class="row-id cell" style="left: 0;">
</div>
<div class="row-title cell" style="left: 50px;">
</div>
<div class="row-text cell" style="left: 100px; width: 200px;">
</div>
</div>
</template>
<script src="../resources/runner.js"></script>
<script>
function runTest() {
var index = 0;
PerfTestRunner.measureTime({
description: "Measures layout performance of a page with lots of absolute positioned elements.",
setup: function() {
document.body.style.display = "none";
PerfTestRunner.forceLayout();
},
run: function() {
document.body.style.display = "block";
PerfTestRunner.forceLayout();
}
});
}
const TOTAL_ROWS = 10000;
const ROW_HEIGHT = 10;
let wrapper = document.getElementById("wrapper");
let template = document.getElementById("row-template");
for (let i = 0; i < TOTAL_ROWS; i++) {
let clone = template.content.cloneNode(true);
let row = clone.querySelector(".row");
row.style.top = (i * ROW_HEIGHT) + "px";
let color = "#"+ ((1<<24)*Math.random()|0).toString(16);
let rowId = clone.querySelector(".row-id");
rowId.innerHTML = "<div style='width: 10px; height: 10px; background: " + color + ";'></div>";
let rowTitle = clone.querySelector(".row-title");
rowTitle.innerHTML = "<div style='width: 25px; height: 5px; background: " + color + ";'></div>";
let rowText = clone.querySelector(".row-text");
rowText.innerHTML = "<div style='width: 50px; height: 5px; background: " + color + ";'></div>";
wrapper.appendChild(clone);
}
runTest();
</script>