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 @@
node_modules

View file

@ -0,0 +1,21 @@
{
"name": "ws-speed-test",
"version": "0.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"ws": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==",
"requires": {
"async-limiter": "~1.0.0"
}
}
}
}

View file

@ -0,0 +1,7 @@
{
"name": "ws-speed-test",
"version": "0.1.0",
"dependencies": {
"ws": "^5.2.2"
}
}

View file

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<script src="../resources/runner.js"></script>
</head>
<body>
<script>
// To run this perf test, you need to run the web socket server:
// $ cd third_party/blink/perf_tests/websocket
// $ npm install
// $ npm start
// $ python ../../../../tools/perf/run_benchmark run blink_perf --browser=canary --test-path=websocket\receive-arraybuffer-1MBx100.html
const params = (new URL(document.location)).searchParams;
const server = params.get("server") || "ws://127.0.0.1:8001/";
PerfTestRunner.log("Connect to " + server);
const iteration = params.get("iteration") || 6;
async function runTestCase() {
const ws = new WebSocket(server);
ws.binaryType = "arraybuffer";
const onOpen = new Promise(resolve => {
ws.onopen = () => {
PerfTestRunner.addRunTestStartMarker();
resolve(PerfTestRunner.now());
};
});
const onClose = new Promise(resolve => {
ws.onclose = () => {
PerfTestRunner.addRunTestEndMarker();
resolve(PerfTestRunner.now());
}
});
const [openTime, closeTime] = await Promise.all([onOpen, onClose]);
const executeTimeInSeconds = (closeTime - openTime) / 1000;
const downloadSpeedInMegaBytesPerSecond = 100 / executeTimeInSeconds;
PerfTestRunner.measureValueAsync(downloadSpeedInMegaBytesPerSecond);
}
let isDone = false;
PerfTestRunner.startMeasureValuesAsync({
description: "Measure performance of receiving 1MB array 100 times.",
unit: 'MB/s',
done: function () {
isDone = true;
},
run: async function() {
while (!isDone) await runTestCase();
},
iterationCount: iteration,
});
</script>
</body>
</html>

View file

@ -0,0 +1,38 @@
const ws = require('ws')
const ws_server = new ws.Server({ host: '0.0.0.0', port: 8001 });
const getNow = () => {
const date = new Date();
return date.toLocaleTimeString() + "." + date.getMilliseconds();
};
console.log(getNow() + " WebSocket server started.");
const arrayBuf = 1000*1000; // 1MB
const totalIter = 100;
const charArray1000 = [];
for (i = 0; i < 1000; i++) {
charArray1000.push(i % 128);
}
const asciiArray1K = String.fromCharCode.apply(this, charArray1000);
const textArray1M = [];
for (i = 0; i < 1000; i++) {
textArray1M.push(asciiArray1K);
}
const asciiText1MB = textArray1M.join('');
ws_server.on('connection', function(ws_socket, request) {
console.log(getNow() + ' Connection established. url=' + request.url);
if (request.url === '/') {
const data = new ArrayBuffer(arrayBuf);
for (let i = 0; i < totalIter; i++) {
ws_socket.send(data, {binary: true});
}
} else if (request.url === '/text') {
for (let i = 0; i < totalIter; i++) {
ws_socket.send(asciiText1MB);
}
} else {
console.log('Invalid request: ' + request.url);
}
ws_socket.close();
console.log(getNow() + " Connection closed.");
});