mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
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>
38 lines
No EOL
1.1 KiB
JavaScript
Vendored
38 lines
No EOL
1.1 KiB
JavaScript
Vendored
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.");
|
|
}); |