servo/tests/blink_perf_tests/perf_tests/paint/custom-highlights.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

47 lines
1.7 KiB
HTML
Vendored

<!DOCTYPE html>
<title>Custom Highlights Painting</title>
<style>
::highlight(example) {
color: blue;
background: yellow;
}
</style>
<script src="../resources/runner.js"></script>
<script src="resources/paint.js"></script>
<pre id="log"></pre>
<script>
// Setting this to larger values can result in "Maximum call stack size exceeded" exceptions, see: https://crbug.com/978832.
const REPETITIONS = 1000;
const LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
let indexesLetterA = [];
for (let i = 0; i < LOREM_IPSUM.length; i++) {
if (LOREM_IPSUM[i] == "a")
indexesLetterA.push(i);
}
let ranges = [];
function setupTest() {
for (let i = 0; i < REPETITIONS; i++) {
let p = document.createElement("p");
p.textContent = LOREM_IPSUM;
document.body.appendChild(p);
indexesLetterA.forEach(index => {
let range = new Range();
range.setStart(p.firstChild, index);
range.setEnd(p.firstChild, index + 1);
ranges.push(range);
});
}
}
setupTest();
measurePaint({
description: "Measure time for painting Custom Highlights (emulates searching 'a' in a large text)",
run: () => CSS.highlights.set("example", new Highlight(...ranges)),
setup: () => CSS.highlights.clear(),
});
</script>