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:
Jonathan Schwender 2025-08-17 11:54:04 +02:00 committed by GitHub
parent 7621332824
commit ee781b71b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
648 changed files with 359694 additions and 0 deletions

View file

@ -0,0 +1,62 @@
<!DOCTYPE html>
<body>
<pre id="log"></pre>
<script src="../resources/runner.js"></script>
<div id="sandbox" style="display:none"></div>
<script>
var sandbox = document.getElementById('sandbox');
var node = sandbox;
for (var i = 0; i < 200; ++i)
node = node.appendChild(document.createElement('div'));
var elems = [];
for (var i = 0; i < 50000; ++i)
elems[i] = document.createElement('div');
var observing = false;
var observer = new WebKitMutationObserver(listener);
var tickledSpan = document.createElement('span');
observer.observe(tickledSpan, {attributes: true});
function resetState() {
window.start = null;
window.numRuns = 25;
window.times = [];
}
function runAgain() {
tickledSpan.setAttribute('data-foo', numRuns);
}
function listener(mutations) {
if (start) {
var time = Date.now() - start;
times.push(time);
PerfTestRunner.log(time);
}
if (numRuns-- >= 0) {
runAgain();
if (observing)
observer.disconnect()
node.innerHTML = '';
if (observing)
observer.observe(sandbox, {childList: true, subtree: true});
start = Date.now();
for (var i = 0; i < elems.length; ++i)
node.appendChild(elems[i]);
} else {
PerfTestRunner.logStatistics(times);
if (!observing) {
observing = true;
resetState();
PerfTestRunner.log('\n------------\n');
PerfTestRunner.log('Running ' + numRuns + ' times with observation');
setTimeout(runAgain, 0);
}
}
}
resetState();
PerfTestRunner.log('Running ' + numRuns + ' times without observation');
window.addEventListener('load', runAgain);
</script>
</body>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<!-- Identical to "append-child.html" but having 100 active ranges -->
<body>
<pre id="log"></pre>
<script src="../resources/runner.js"></script>
<div id="sandbox" style="display:none"></div>
<script>
var elems = [];
for (var i = 0; i < 50000; ++i)
elems[i] = document.createElement('div');
var ranges = [];
for (var i = 0; i < 100; ++i) {
var range = new Range();
ranges[i] = range;
range.selectNodeContents(document.body);
}
var sandbox = document.getElementById('sandbox');
PerfTestRunner.measureRunsPerSecond({
description: 'Measures performance of appendChild with active Range objects',
run: function() {
for (var elem of elems)
sandbox.appendChild(elem);
}
});
</script>
</body>

View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<body>
<pre id="log"></pre>
<script src="../resources/runner.js"></script>
<div id="sandbox" style="display:none"></div>
<script>
var sandbox = document.getElementById('sandbox');
var observing = false;
var elems = [];
for (var i = 0; i < 50000; ++i)
elems[i] = document.createElement('div');
var observer = new WebKitMutationObserver(listener);
var tickledSpan = document.createElement('span');
observer.observe(tickledSpan, {attributes: true});
function resetState() {
window.start = null;
window.numRuns = 25;
window.times = [];
}
function runAgain() {
tickledSpan.setAttribute('data-foo', numRuns);
}
function listener(mutations) {
if (start) {
var time = Date.now() - start;
times.push(time);
PerfTestRunner.log(time);
}
if (numRuns-- >= 0) {
runAgain();
if (observing)
observer.disconnect()
sandbox.innerHTML = '';
if (observing)
observer.observe(sandbox, {childList: true});
start = Date.now();
for (var i = 0; i < elems.length; ++i)
sandbox.appendChild(elems[i]);
} else {
PerfTestRunner.logStatistics(times);
if (!observing) {
observing = true;
resetState();
PerfTestRunner.log('\n------------\n');
PerfTestRunner.log('Running ' + numRuns + ' times with observation');
setTimeout(runAgain, 0);
}
}
}
resetState();
PerfTestRunner.log('Running ' + numRuns + ' times without observation');
window.addEventListener('load', runAgain);
</script>
</body>

View file

@ -0,0 +1,55 @@
<!DOCTYPE html>
<body>
<pre id="log"></pre>
<script src="../resources/runner.js"></script>
<div id="sandbox" style="display:none"></div>
<script>
var sandbox = document.getElementById('sandbox');
var observing = false;
for (var i = 0; i < 1000; ++i)
sandbox.appendChild(document.createElement('div'));
var html = sandbox.innerHTML;
var observer = new WebKitMutationObserver(listener);
var tickledSpan = document.createElement('span');
observer.observe(tickledSpan, {attributes: true});
function resetState() {
window.start = null;
window.numRuns = 25;
window.times = [];
}
function runAgain() {
tickledSpan.setAttribute('data-foo', numRuns);
}
function listener(mutations) {
if (start) {
var time = Date.now() - start;
times.push(time);
PerfTestRunner.log(time);
}
if (numRuns-- >= 0) {
runAgain();
start = Date.now();
for (var i = 0; i < 100; ++i)
sandbox.innerHTML = html;
} else {
PerfTestRunner.logStatistics(times);
if (!observing) {
observer.observe(sandbox, {childList: true});
observing = true;
resetState();
PerfTestRunner.log('\n------------\n');
PerfTestRunner.log('Running ' + numRuns + ' times with observation');
setTimeout(runAgain, 0);
}
}
}
resetState();
PerfTestRunner.log('Running ' + numRuns + ' times without observation');
window.addEventListener('load', runAgain);
</script>
</body>

View file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<body>
<script src="../resources/runner.js"></script>
<style>td { border: 1px solid blue }</style>
<script>
function createTable(rows, columns) {
var table = document.createElement("TABLE");
// Collapsing border is not necessary to see the slowness
// but it makes the painting phase ~2x slower.
table.style.borderCollapse = "collapse";
for (var i = 0; i < rows; ++i) {
var tr = document.createElement("TR");
for (var j = 0; j < columns; ++j) {
var td = document.createElement("TD");
tr.appendChild(td);
}
table.appendChild(tr);
}
return table;
}
var table = createTable(400, 400);
document.body.appendChild(table);
var y = 0;
PerfTestRunner.measureFrameTime({
run: function() {
table.childNodes[y].style.height = '20px';
y++;
},
});
</script>
</body>

View file

@ -0,0 +1,66 @@
<!DOCTYPE html>
<body>
<pre id="log"></pre>
<script src="../resources/runner.js"></script>
<div id="sandbox" style="display:none"></div>
<script>
var sandbox = document.getElementById('sandbox');
var node = sandbox;
for (var i = 0; i < 200; ++i)
node = node.appendChild(document.createElement('div'));
var observing = false;
var observer = new WebKitMutationObserver(listener);
var tickledSpan = document.createElement('span');
observer.observe(tickledSpan, {attributes: true});
function resetState() {
window.start = null;
window.numRuns = 25;
window.times = [];
}
function runAgain() {
tickledSpan.setAttribute('data-foo', numRuns);
}
function hideFromObservation(func) {
if (observing)
observer.disconnect();
func();
if (observing)
observer.observe(sandbox, {childList: true, subtree: true});
}
function listener(mutations) {
if (start) {
var time = Date.now() - start;
times.push(time);
PerfTestRunner.log(time);
}
if (numRuns-- >= 0) {
runAgain();
hideFromObservation(function() {
for (var i = 0; i < 50000; ++i)
node.appendChild(document.createElement('div'));
});
start = Date.now();
while (node.firstChild)
node.removeChild(node.firstChild);
} else {
PerfTestRunner.logStatistics(times);
if (!observing) {
observing = true;
resetState();
PerfTestRunner.log('\n------------\n');
PerfTestRunner.log('Running ' + numRuns + ' times with observation');
setTimeout(runAgain, 0);
}
}
}
resetState();
PerfTestRunner.log('Running ' + numRuns + ' times without observation');
window.addEventListener('load', runAgain);
</script>
</body>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- Identical to "remove-child.html" but having 100 active ranges -->
<body>
<pre id="log"></pre>
<script src="../resources/runner.js"></script>
<div id="sandbox" style="display:none"></div>
<script>
var elems = [];
for (var i = 0; i < 50000; ++i)
elems[i] = document.createElement('div');
var ranges = [];
for (var i = 0; i < 1000; ++i) {
var range = new Range();
ranges[i] = range;
range.selectNodeContents(document.body);
}
var sandbox = document.getElementById('sandbox');
PerfTestRunner.measureRunsPerSecond({
description: 'Measures performance of removeChild with active Range objects',
run: function() {
for (var elem of elems)
sandbox.appendChild(elem);
while (sandbox.firstChild)
sandbox.firstChild.remove();
}
});
</script>
</body>

View file

@ -0,0 +1,64 @@
<!DOCTYPE html>
<body>
<pre id="log"></pre>
<script src="../resources/runner.js"></script>
<div id="sandbox" style="display:none"></div>
<script>
var sandbox = document.getElementById('sandbox');
var observing = false;
var observer = new WebKitMutationObserver(listener);
var tickledSpan = document.createElement('span');
observer.observe(tickledSpan, {attributes: true});
function resetState() {
window.start = null;
window.numRuns = 25;
window.times = [];
}
function runAgain() {
tickledSpan.setAttribute('data-foo', numRuns);
}
function hideFromObservation(func) {
if (observing)
observer.disconnect()
func();
if (observing)
observer.observe(sandbox, {childList: true});
}
function listener(mutations) {
if (start) {
var time = Date.now() - start;
times.push(time);
PerfTestRunner.log(time);
}
if (numRuns-- >= 0) {
runAgain();
hideFromObservation(function() {
for (var i = 0; i < 50000; ++i)
sandbox.appendChild(document.createElement('div'));
});
start = Date.now();
while (sandbox.firstChild)
sandbox.removeChild(sandbox.firstChild);
} else {
PerfTestRunner.logStatistics(times);
if (!observing) {
observer.observe(sandbox, {childList: true});
observing = true;
resetState();
PerfTestRunner.log('\n------------\n');
PerfTestRunner.log('Running ' + numRuns + ' times with observation');
setTimeout(runAgain, 0);
}
}
}
resetState();
PerfTestRunner.log('Running ' + numRuns + ' times without observation');
window.addEventListener('load', runAgain);
</script>
</body>