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,16 @@
/**
* @class BypassProcessor
* @extends AudioWorkletProcessor
*/
class BypassProcessor extends AudioWorkletProcessor {
process(inputs, outputs) {
let input = inputs[0];
let output = outputs[0];
for (let channel = 0; channel < input.length; ++channel)
output[channel].set(input[channel]);
return true;
}
}
registerProcessor('bypass-processor', BypassProcessor);

View file

@ -0,0 +1,100 @@
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Set up and perform a test with given test options.
*
* @param {!object} testOptions
* @param {string} testOptions.description test description
* @param {function} testOptions.graphBuilder a test function returns an
* OfflineAudioContext.
* @param {object} testOptions.tracingOptions test options
* @param {string} testOptions.tracingOptions.targetCategory
* target trace category
* @param {Array<string>} testOptions.tracingOptions.targetEvents
* target trace events
*/
function RunWebAudioPerfTest(testOptions) {
let isDone = false;
let startTime;
async function runTest_internal() {
const context = await testOptions.graphBuilder();
PerfTestRunner.addRunTestStartMarker();
startTime = PerfTestRunner.now();
await context.startRendering();
PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
PerfTestRunner.addRunTestEndMarker();
if (!isDone)
runTest_internal();
}
PerfTestRunner.startMeasureValuesAsync({
unit: 'ms',
description: testOptions.description,
done: () => isDone = true,
run: runTest_internal,
warmUpCount: 2,
iterationCount: 5,
tracingCategories: testOptions.tracingOptions.targetCategory,
traceEventsToMeasure: testOptions.tracingOptions.targetEvents,
});
}
/**
* Creates multiple AudioNodes that are serially connected
*
* @param {BaseAudioContext} context
* @param {string} nodeName AudioNode name in string
* @param {number} numberOfNodes
* @param {AudioNodeOptions} nodeOptions
* @returns {object}
*/
function createAndConnectNodesInSeries(
context, nodeName, numberOfNodes, nodeOptions) {
const testNodes = [];
nodeOptions = nodeOptions || {};
for (let i = 0; i < numberOfNodes; ++i) {
testNodes.push(new window[nodeName](context, nodeOptions));
if (i === 0) continue;
testNodes[i - 1].connect(testNodes[i]);
}
return {
head: testNodes[0],
tail: testNodes[numberOfNodes - 1],
nodes: testNodes,
};
}
/**
* Creates multiple AudioNodes.
*
* @param {BaseAudioContext} context
* @param {string} nodeName AudioNode name in string
* @param {number} numberOfNodes
* @param {AudioNodeOptions} nodeOptions
* @returns {Array<AudioNode>}
*/
function createNodes(context, nodeName, numberOfNodes, nodeOptions) {
const testNodes = [];
nodeOptions = nodeOptions || {};
for (let i = 0; i < numberOfNodes; ++i)
testNodes.push(new window[nodeName](context, nodeOptions));
return testNodes;
}
/**
* Creates an AudioBuffer with up-ramp samples.
*
* @param {number} length number of samples
* @param {number} sampleRate sample rate
* @returns {AudioBuffer}
*/
function createMonoRampBuffer(length, sampleRate) {
let buffer = new AudioBuffer({numberOfChannel: 1, length, sampleRate});
let channelData = buffer.getChannelData(0);
for (let i = 0; i < length; ++i)
channelData[i] = i / length;
return buffer;
}