mirror of
https://github.com/servo/servo.git
synced 2025-09-11 07:28:19 +01:00
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>
This commit is contained in:
parent
7621332824
commit
ee781b71b4
648 changed files with 359694 additions and 0 deletions
|
@ -0,0 +1,78 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
div {
|
||||
position: relative;
|
||||
padding: 2px;
|
||||
border: 1px solid black;
|
||||
min-width: 10px;
|
||||
min-height: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body></body>
|
||||
|
||||
<script src='../resources/runner.js'></script>
|
||||
<script src='../resources/generate-chrome-class-name.js'></script>
|
||||
<script>
|
||||
|
||||
// To generate profile data for analysis with pprof, set generateProfile to
|
||||
// 'true' and run chrome with "--enable-gpu-benchmarking --no-sandbox".
|
||||
const generateProfile = false;
|
||||
|
||||
// How many targets.
|
||||
const breadth = 32;
|
||||
// How many levels of DOM hierarchy above each target.
|
||||
const depth = 16;
|
||||
// How many observers.
|
||||
const redundancy = 1000;
|
||||
|
||||
// The total number of observations is breadth * redundancy.
|
||||
|
||||
function populate(level) {
|
||||
let div = document.createElement('div');
|
||||
if (level == 0) {
|
||||
div.classList = ['leaf'];
|
||||
} else {
|
||||
let child = populate(level - 1);
|
||||
div.appendChild(child);
|
||||
}
|
||||
return div;
|
||||
}
|
||||
|
||||
for (let i = 0; i < breadth; i++) {
|
||||
document.body.appendChild(populate(depth));
|
||||
}
|
||||
|
||||
for (let i = 0; i < redundancy; i++) {
|
||||
let observer = new IntersectionObserver(() => {});
|
||||
document.querySelectorAll('.leaf').forEach((target) => { observer.observe(target) });
|
||||
}
|
||||
|
||||
PerfTestRunner.measureFrameTime({
|
||||
description: 'Frame time with lots of intersection observers in a deep layer tree.',
|
||||
tracingCategories: 'blink',
|
||||
traceEventsToMeasure: ['LocalFrameView::UpdateViewportIntersectionsForSubtree'],
|
||||
setup: () => {
|
||||
document.querySelectorAll('.leaf').forEach(leaf => {
|
||||
leaf.innerText = generateChromeClassName();
|
||||
});
|
||||
// Force layout so that layout cost isn't included in measured time.
|
||||
document.querySelector('.leaf').offsetTop;
|
||||
if (window.internals)
|
||||
internals.clearGeometryMapperCache();
|
||||
if (generateProfile && self.chrome && chrome.gpuBenchmarking) {
|
||||
chrome.gpuBenchmarking.startProfiling('perf.data');
|
||||
}
|
||||
},
|
||||
run: () => {},
|
||||
done: () => {
|
||||
if (generateProfile && self.chrome && chrome.gpuBenchmarking) {
|
||||
chrome.gpuBenchmarking.stopProfiling();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,97 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
.container {
|
||||
margin: 4px;
|
||||
display: inline-block;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
.vscroller {
|
||||
overflow-y: overlay;
|
||||
max-height: 300px;
|
||||
border: 2px solid black;
|
||||
padding: 2px;
|
||||
background-color: white;
|
||||
}
|
||||
.item-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: start;
|
||||
contain: paint;
|
||||
}
|
||||
.item {
|
||||
font-size: 18px;
|
||||
flex: 0;
|
||||
margin: 1px 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body></body>
|
||||
|
||||
<script src='../resources/runner.js'></script>
|
||||
<script src='../resources/generate-chrome-class-name.js'></script>
|
||||
<script>
|
||||
|
||||
// To generate profile data for analysis with pprof, set generateProfile to
|
||||
// 'true' and run chrome with "--enable-gpu-benchmarking --no-sandbox".
|
||||
const generateProfile = false;
|
||||
|
||||
// How many observed list items.
|
||||
const numItems = 100000;
|
||||
// How many levels of DOM hierarchy between the scrolling root and list items.
|
||||
const containerDepth = 100;
|
||||
// How far to scroll on each frame.
|
||||
const velocity = 1000;
|
||||
|
||||
let scroller = document.createElement('div');
|
||||
scroller.classList.add('vscroller');
|
||||
document.body.appendChild(scroller);
|
||||
let parent = scroller;
|
||||
for (let i = 0; i < containerDepth; i++) {
|
||||
let container = document.createElement('div');
|
||||
container.classList.add('container');
|
||||
parent.appendChild(container);
|
||||
parent = container;
|
||||
}
|
||||
let itemContainer = document.createElement('div');
|
||||
itemContainer.classList.add('item-container');
|
||||
parent.appendChild(itemContainer);
|
||||
parent = itemContainer;
|
||||
|
||||
let observer = new IntersectionObserver(entries => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.intersectionRatio > 0) {
|
||||
entry.target.classList.add('visible');
|
||||
} else {
|
||||
entry.target.classList.remove('visible');
|
||||
}
|
||||
});
|
||||
}, { root: scroller });
|
||||
|
||||
for (let i = 0; i < numItems; i++) {
|
||||
let item = document.createElement('div');
|
||||
item.classList.add('item');
|
||||
parent.appendChild(item);
|
||||
item.innerText = generateChromeClassName();
|
||||
observer.observe(item);
|
||||
}
|
||||
|
||||
PerfTestRunner.measureFrameTime({
|
||||
description: 'Frame time with one IntersectionObserver with a scrolling root element, observing many items.',
|
||||
tracingCategories: 'blink',
|
||||
traceEventsToMeasure: ['LocalFrameView::UpdateViewportIntersectionsForSubtree'],
|
||||
setup: () => {
|
||||
let max_scroll = scroller.scrollHeight - scroller.clientHeight;
|
||||
scroller.scrollTop = (scroller.scrollTop + velocity) % max_scroll;
|
||||
if (generateProfile && self.chrome && chrome.gpuBenchmarking) {
|
||||
chrome.gpuBenchmarking.startProfiling('perf.data');
|
||||
}
|
||||
},
|
||||
run: () => {},
|
||||
done: () => {
|
||||
if (generateProfile && self.chrome && chrome.gpuBenchmarking) {
|
||||
chrome.gpuBenchmarking.stopProfiling();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue