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,6 @@
<!DOCTYPE HTML>
<!-- This page forces a GC in DRT for https://bugs.webkit.org/show_bug.cgi?id=98203. -->
<html>
<body onload="window.GCController.collect();">
</body>
</html>

View file

@ -0,0 +1,140 @@
(function() {
let prefixes = [
'Accessibility',
'Async',
'Background',
'Browser',
'Child',
'Common',
'Core',
'Internal',
'Main',
'Mock',
'Platform',
'Private',
'Render',
'Root',
'Scoped',
'Session',
'Shared',
'Stub',
'Synchronous',
'Test',
'Web',
];
let bases = [
'Audio',
'Auth',
'Authentication',
'Blob',
'Bluetooth',
'Box',
'Cache',
'Capture',
'Compositor',
'Connection',
'Contents',
'Context',
'Cookie',
'Cursor',
'Devtools',
'Download',
'Drag',
'Endpoint',
'Execution',
'File',
'Frame',
'Gesture',
'Graphics',
'Handle',
'Handler',
'Index',
'Intersection',
'Keyboard',
'Layer',
'Layout',
'Loader',
'Loop',
'Mailbox',
'Media',
'Metrics',
'Mouse',
'Navigation',
'Network',
'Node',
'Package',
'Paint',
'Partition',
'Player',
'Process',
'Queue',
'Quota',
'Registry',
'Request',
'Response',
'Sandbox',
'Selection',
'Service',
'Site',
'Storage',
'Stream',
'Tab',
'Task',
'Texture',
'Theme',
'Thread',
'Throttling',
'Tool',
'Touch',
'Tracker',
'Transaction',
'URL',
'Video',
'Widget',
'Window',
'Worker',
];
let suffixes = [
'Client',
'Connector',
'Delegate',
'Dispatcher',
'Factory',
'FactoryFactory',
'Helper',
'Host',
'Impl',
'Injection',
'Instance',
'Mananger',
'Monitor',
'Observer',
'Protocol',
'Provider',
'Proxy',
'Reader',
'Receiver',
'Scope',
'State',
'Tree',
'Util',
'View',
'Writer',
];
window.generateChromeClassName = () => {
let s = "";
let count = Math.round(Math.random() * 2);
for (let j = 0; j < count; j++)
s += prefixes[Math.floor(Math.random() * prefixes.length)];
count = Math.ceil(Math.random() * 3);
for (let j = 0; j < count; j++)
s += bases[Math.floor(Math.random() * bases.length)];
count = Math.round(Math.random() * 4);
for (let j = 0; j < count; j++)
s += suffixes[Math.floor(Math.random() * suffixes.length)];
return s;
};
})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,530 @@
// There are tests for computeStatistics() located in LayoutTests/fast/harness/perftests
if (window.testRunner) {
testRunner.waitUntilDone();
testRunner.dumpAsText();
}
(function () {
var logLines = null;
var completedIterations = -1;
var callsPerIteration = 1;
var currentTest = null;
var results = [];
var jsHeapResults = [];
var iterationCount = undefined;
var PerfTestRunner = {};
// To make the benchmark results predictable, we replace Math.random with a
// 100% deterministic alternative.
PerfTestRunner.randomSeed = PerfTestRunner.initialRandomSeed = 49734321;
PerfTestRunner.resetRandomSeed = function() {
PerfTestRunner.randomSeed = PerfTestRunner.initialRandomSeed
}
PerfTestRunner.random = Math.random = function() {
// Robert Jenkins' 32 bit integer hash function.
var randomSeed = PerfTestRunner.randomSeed;
randomSeed = ((randomSeed + 0x7ed55d16) + (randomSeed << 12)) & 0xffffffff;
randomSeed = ((randomSeed ^ 0xc761c23c) ^ (randomSeed >>> 19)) & 0xffffffff;
randomSeed = ((randomSeed + 0x165667b1) + (randomSeed << 5)) & 0xffffffff;
randomSeed = ((randomSeed + 0xd3a2646c) ^ (randomSeed << 9)) & 0xffffffff;
randomSeed = ((randomSeed + 0xfd7046c5) + (randomSeed << 3)) & 0xffffffff;
randomSeed = ((randomSeed ^ 0xb55a4f09) ^ (randomSeed >>> 16)) & 0xffffffff;
PerfTestRunner.randomSeed = randomSeed;
return (randomSeed & 0xfffffff) / 0x10000000;
};
PerfTestRunner.now = window.performance && window.performance.now ? function () { return window.performance.now(); } : Date.now;
PerfTestRunner.logInfo = function (text) {
if (!window.testRunner)
this.log(text);
}
PerfTestRunner.loadFile = function (path) {
var xhr = new XMLHttpRequest();
xhr.open("GET", path, false);
xhr.send(null);
return xhr.responseText;
}
PerfTestRunner.computeStatistics = function (times, unit) {
var data = times.slice();
// Add values from the smallest to the largest to avoid the loss of significance
data.sort(function(a,b){return a-b;});
var middle = Math.floor(data.length / 2);
var result = {
min: data[0],
max: data[data.length - 1],
median: data.length % 2 ? data[middle] : (data[middle - 1] + data[middle]) / 2,
};
// Compute the mean and variance using Knuth's online algorithm (has good numerical stability).
var squareSum = 0;
result.values = times;
result.mean = 0;
for (var i = 0; i < data.length; ++i) {
var x = data[i];
var delta = x - result.mean;
var sweep = i + 1.0;
result.mean += delta / sweep;
squareSum += delta * (x - result.mean);
}
result.variance = data.length <= 1 ? 0 : squareSum / (data.length - 1);
result.stdev = Math.sqrt(result.variance);
result.unit = unit || "ms";
return result;
}
PerfTestRunner.logStatistics = function (values, unit, title) {
var statistics = this.computeStatistics(values, unit);
this.log("");
this.log(title);
if (statistics.values)
this.log("values " + statistics.values.join(", ") + " " + statistics.unit);
this.log("avg " + statistics.mean + " " + statistics.unit);
this.log("median " + statistics.median + " " + statistics.unit);
this.log("stdev " + statistics.stdev + " " + statistics.unit);
this.log("min " + statistics.min + " " + statistics.unit);
this.log("max " + statistics.max + " " + statistics.unit);
}
function getUsedJSHeap() {
return console.memory.usedJSHeapSize;
}
PerfTestRunner.gc = function () {
if (window.GCController)
window.GCController.collectAll();
else {
function gcRec(n) {
if (n < 1)
return {};
var temp = {i: "ab" + i + (i / 100000)};
temp += "foo";
gcRec(n-1);
}
for (var i = 0; i < 1000; i++)
gcRec(10);
}
};
function logInDocument(text) {
if (!document.getElementById("log")) {
var pre = document.createElement("pre");
pre.id = "log";
document.body.appendChild(pre);
}
document.getElementById("log").innerHTML += text + "\n";
}
PerfTestRunner.log = function (text) {
if (logLines)
logLines.push(text);
else
logInDocument(text);
}
PerfTestRunner.logFatalError = function (text) {
PerfTestRunner.log("FATAL: " + text);
finish();
}
PerfTestRunner.assert_true = function (cond,text) {
if (cond)
return;
PerfTestRunner.logFatalError(text);
}
PerfTestRunner.assert_false = function (cond,text) {
PerfTestRunner.assert_true(!cond,text);
}
PerfTestRunner.formatException = function (text, exception) {
return "Got an exception while " + text +
" with name=" + exception.name +
", message=" + exception.message +
"\n" + exception.stack;
}
PerfTestRunner.logException = function (text, exception) {
PerfTestRunner.logFatalError(PerfTestRunner.formatException(text, exception));
}
PerfTestRunner.forceLayout = function(doc) {
doc = doc || document;
if (doc.body)
doc.body.offsetHeight;
else if (doc.documentElement)
doc.documentElement.offsetHeight;
};
function start(test, scheduler, runner) {
if (!test || !runner) {
PerfTestRunner.logFatalError("Got a bad test object.");
return;
}
currentTest = test;
if (test.tracingCategories && !test.traceEventsToMeasure) {
PerfTestRunner.logFatalError("test's tracingCategories is " +
"specified but test's traceEventsToMeasure is empty");
return;
}
if (test.traceEventsToMeasure && !test.tracingCategories) {
PerfTestRunner.logFatalError("test's traceEventsToMeasure is " +
"specified but test's tracingCategories is empty");
return;
}
iterationCount = test.iterationCount || (window.testRunner ? 5 : 20);
if (test.warmUpCount && test.warmUpCount > 0)
completedIterations = -test.warmUpCount;
logLines = PerfTestRunner.bufferedLog || window.testRunner ? [] : null;
// Tests that run in workers are not impacted by the iteration control.
if (!currentTest.runInWorker) {
PerfTestRunner.log("Running " + iterationCount + " times");
}
if (test.doNotIgnoreInitialRun)
completedIterations++;
if (window.testRunner && window.testRunner.telemetryIsRunning) {
testRunner.waitForTelemetry(test.tracingCategories, function() {
scheduleNextRun(scheduler, runner);
});
return;
}
if (test.tracingCategories) {
PerfTestRunner.log("Tracing based metrics are specified but " +
"tracing is not supported on this platform. To get those " +
"metrics from this test, you can run the test using " +
"tools/perf/run_benchmarks script.");
}
scheduleNextRun(scheduler, runner);
}
function scheduleNextRun(scheduler, runner) {
if (!scheduler) {
// This is an async measurement test which has its own scheduler.
try {
runner();
} catch (exception) {
PerfTestRunner.logException("running test.run", exception);
}
return;
}
scheduler(function () {
// This will be used by tools/perf/benchmarks/blink_perf.py to find
// traces during the measured runs.
if (completedIterations >= 0)
console.time("blink_perf");
try {
if (currentTest.setup)
currentTest.setup();
var measuredValue = runner();
if (currentTest.teardown)
currentTest.teardown();
} catch (exception) {
PerfTestRunner.logException("running test.run", exception);
return;
}
completedIterations++;
try {
ignoreWarmUpAndLog(measuredValue);
} catch (exception) {
PerfTestRunner.logException("logging the result", exception);
return;
}
if (completedIterations < iterationCount)
scheduleNextRun(scheduler, runner);
else
finish();
});
}
function ignoreWarmUpAndLog(measuredValue) {
var labeledResult = measuredValue + " " + PerfTestRunner.unit;
// Tests that run in workers are not impacted by the iteration control.
if (!currentTest.runInWorker && completedIterations <= 0)
PerfTestRunner.log("Ignoring warm-up run (" + labeledResult + ")");
else {
results.push(measuredValue);
if (window.internals && !currentTest.doNotMeasureMemoryUsage) {
jsHeapResults.push(getUsedJSHeap());
}
PerfTestRunner.log(labeledResult);
}
}
function finish() {
try {
// The blink_perf timer is only started for non-worker test.
if (!currentTest.runInWorker)
console.timeEnd("blink_perf");
if (currentTest.description)
PerfTestRunner.log("Description: " + currentTest.description);
PerfTestRunner.logStatistics(results, PerfTestRunner.unit, "Time:");
if (jsHeapResults.length) {
PerfTestRunner.logStatistics(jsHeapResults, "bytes", "JS Heap:");
}
if (logLines)
logLines.forEach(logInDocument);
window.scrollTo(0, document.body.offsetHeight);
if (currentTest.done)
currentTest.done();
} catch (exception) {
logInDocument(PerfTestRunner.formatException("finalizing the test", exception));
}
if (window.testRunner) {
if (currentTest.traceEventsToMeasure &&
testRunner.telemetryIsRunning) {
testRunner.stopTracingAndMeasure(
currentTest.traceEventsToMeasure, function() {
testRunner.notifyDone();
});
} else {
testRunner.notifyDone();
}
}
}
PerfTestRunner.startMeasureValuesAsync = function (test) {
PerfTestRunner.unit = test.unit;
start(test, undefined, function() { test.run() });
}
PerfTestRunner.measureValueAsync = function (measuredValue) {
completedIterations++;
try {
ignoreWarmUpAndLog(measuredValue);
} catch (exception) {
PerfTestRunner.logFatalError("Got an exception while logging the result with name=" + exception.name + ", message=" + exception.message);
return;
}
if (completedIterations >= iterationCount)
finish();
}
PerfTestRunner.addRunTestStartMarker = function () {
if (!window.testRunner || !window.testRunner.telemetryIsRunning)
return;
if (completedIterations < 0)
console.time('blink_perf.runTest.warmup');
else
console.time('blink_perf.runTest');
};
PerfTestRunner.addRunTestEndMarker = function () {
if (!window.testRunner || !window.testRunner.telemetryIsRunning)
return;
if (completedIterations < 0)
console.timeEnd('blink_perf.runTest.warmup');
else
console.timeEnd('blink_perf.runTest');
};
PerfTestRunner.measureFrameTime = function (test) {
PerfTestRunner.unit = "ms";
PerfTestRunner.bufferedLog = true;
test.warmUpCount = test.warmUpCount || 5;
test.iterationCount = test.iterationCount || 10;
// Force gc before starting the test to avoid the measured time from
// being affected by gc performance. See crbug.com/667811#c16.
PerfTestRunner.gc();
start(test, requestAnimationFrame, measureFrameTimeOnce);
}
PerfTestRunner.measureInnerRAFTime = function (test) {
PerfTestRunner.unit = "ms";
PerfTestRunner.bufferedLog = true;
test.warmUpCount = test.warmUpCount || 5;
test.iterationCount = test.iterationCount || 10;
// Force gc before starting the test to avoid the measured time from
// being affected by gc performance. See crbug.com/667811#c16.
PerfTestRunner.gc();
start(test, requestAnimationFrame, measureTimeOnce);
}
var lastFrameTime = -1;
function measureFrameTimeOnce() {
var now = PerfTestRunner.now();
var result = lastFrameTime == -1 ? -1 : now - lastFrameTime;
lastFrameTime = now;
PerfTestRunner.addRunTestStartMarker();
var returnValue = currentTest.run();
requestAnimationFrame(function() {
PerfTestRunner.addRunTestEndMarker();
});
if (returnValue - 0 === returnValue) {
if (returnValue < 0)
PerfTestRunner.log("runFunction returned a negative value: " + returnValue);
return returnValue;
}
return result;
}
PerfTestRunner.measureTime = function (test) {
PerfTestRunner.unit = "ms";
PerfTestRunner.bufferedLog = true;
start(test, zeroTimeoutScheduler, measureTimeOnce);
}
PerfTestRunner.measureValue = function (test) {
PerfTestRunner.unit = test.unit;
start(test, zeroTimeoutScheduler, measureTimeOnce);
}
function zeroTimeoutScheduler(task) {
setTimeout(task, 0);
}
function measureTimeOnce() {
// Force gc before measuring time to avoid interference between tests.
PerfTestRunner.gc();
PerfTestRunner.addRunTestStartMarker();
var start = PerfTestRunner.now();
var returnValue = currentTest.run();
var end = PerfTestRunner.now();
PerfTestRunner.addRunTestEndMarker();
if (returnValue - 0 === returnValue) {
if (returnValue < 0)
PerfTestRunner.log("runFunction returned a negative value: " + returnValue);
return returnValue;
}
return end - start;
}
PerfTestRunner.measureRunsPerSecond = function (test) {
PerfTestRunner.unit = "runs/s";
start(test, zeroTimeoutScheduler, measureRunsPerSecondOnce);
}
function measureRunsPerSecondOnce() {
var timeToRun = 750;
var totalTime = 0;
var numberOfRuns = 0;
while (totalTime < timeToRun) {
totalTime += callRunAndMeasureTime(callsPerIteration);
numberOfRuns += callsPerIteration;
if (completedIterations < 0 && totalTime < 100)
callsPerIteration = Math.max(10, 2 * callsPerIteration);
}
return numberOfRuns * 1000 / totalTime;
}
function callRunAndMeasureTime(callsPerIteration) {
// Force gc before measuring time to avoid interference between tests.
PerfTestRunner.gc();
var startTime = PerfTestRunner.now();
for (var i = 0; i < callsPerIteration; i++)
currentTest.run();
return PerfTestRunner.now() - startTime;
}
PerfTestRunner.measurePageLoadTime = function(test) {
var file = PerfTestRunner.loadFile(test.path);
test.run = function() {
if (!test.chunkSize)
this.chunkSize = 50000;
var chunks = [];
// The smaller the chunks the more style resolves we do.
// Smaller chunk sizes will show more samples in style resolution.
// Larger chunk sizes will show more samples in line layout.
// Smaller chunk sizes run slower overall, as the per-chunk overhead is high.
var chunkCount = Math.ceil(file.length / this.chunkSize);
for (var chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++) {
var chunk = file.substr(chunkIndex * this.chunkSize, this.chunkSize);
chunks.push(chunk);
}
PerfTestRunner.logInfo("Testing " + file.length + " byte document in " + chunkCount + " " + this.chunkSize + " byte chunks.");
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
iframe.sandbox = ''; // Prevent external loads which could cause write() to return before completing the parse.
iframe.style.width = "600px"; // Have a reasonable size so we're not line-breaking on every character.
iframe.style.height = "800px";
iframe.contentDocument.open();
for (var chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
iframe.contentDocument.write(chunks[chunkIndex]);
PerfTestRunner.forceLayout(iframe.contentDocument);
}
iframe.contentDocument.close();
document.body.removeChild(iframe);
};
PerfTestRunner.measureTime(test);
}
// Used for tests that run in workers.
// 1. Call this method to trigger the test. It should be used together
// with |WorkerTestHelper.measureRunsPerSecond()| which is defined in
// src/third_party/blink/perf_tests/resources/worker-test-helper.js.
// 2. The iteration control parameters (test.iterationCount,
// test.doNotIgnoreInitialRun, and test.warmUpCount) are ignored.
// Use parameters of |measureRunsPerSecond()| to control iteration.
// 3. Test result should be sent to the page where the test is triggered.
// Then the result should be recorded by |recordResultFromWorker()| to
// finish the test.
PerfTestRunner.startMeasureValuesInWorker = function (test) {
PerfTestRunner.unit = test.unit;
test.runInWorker = true;
start(test, undefined, function() { test.run(); });
}
// Used for tests that run in workers.
// This method records the result posted from worker thread and finishes the test.
PerfTestRunner.recordResultFromWorker = function(result) {
if (result.error) {
PerfTestRunner.logFatalError(result.error);
return;
}
PerfTestRunner.log("Running " + result.values.length + " times");
try {
result.values.forEach((value) => {
ignoreWarmUpAndLog(value);
});
} catch (exception) {
PerfTestRunner.logFatalError("Got an exception while logging the result with name=" + exception.name + ", message=" + exception.message);
return;
}
finish();
}
window.PerfTestRunner = PerfTestRunner;
})();

View file

@ -0,0 +1,189 @@
/*
* Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
var Statistics = new (function () {
this.max = function (values) {
var maxVal = values[0];
for (var i = 1; i < values.length; i++) {
maxVal = Math.max(maxVal, values[i]);
}
return maxVal;
}
this.min = function (values) {
var minVal = values[0];
for (var i = 1; i < values.length; i++) {
minVal = Math.min(minVal, values[i]);
}
return minVal;
}
this.sum = function (values) {
return values.reduce(function (a, b) { return a + b; }, 0);
}
this.squareSum = function (values) {
return values.reduce(function (sum, value) { return sum + value * value;}, 0);
}
// With sum and sum of squares, we can compute the sample standard deviation in O(1).
// See https://rniwa.com/2012-11-10/sample-standard-deviation-in-terms-of-sum-and-square-sum-of-samples/
this.sampleStandardDeviation = function (numberOfSamples, sum, squareSum) {
if (numberOfSamples < 2)
return 0;
return Math.sqrt(squareSum / (numberOfSamples - 1)
- sum * sum / (numberOfSamples - 1) / numberOfSamples);
}
this.supportedConfidenceLevels = function () {
var supportedLevels = [];
for (var quantile in tDistributionInverseCDF)
supportedLevels.push((1 - (1 - quantile) * 2).toFixed(2));
return supportedLevels;
}
// Computes the delta d s.t. (mean - d, mean + d) is the confidence interval with the specified confidence level in O(1).
this.confidenceIntervalDelta = function (confidenceLevel, numberOfSamples, sum, squareSum) {
var probability = (1 - (1 - confidenceLevel) / 2);
if (!(probability in tDistributionInverseCDF)) {
console.warn('We only support ' + this.supportedConfidenceLevels().map(
function (level) { return level * 100 + '%'; } ).join(', ') + ' confidence intervals.');
return NaN;
}
if (numberOfSamples < 2)
return Number.POSITIVE_INFINITY;
var cdfForProbability = tDistributionInverseCDF[probability];
var degreesOfFreedom = numberOfSamples - 1;
// tDistributionQuantile(degreesOfFreedom, confidenceLevel) * sampleStandardDeviation / sqrt(numberOfSamples) * S/sqrt(numberOfSamples)
if (degreesOfFreedom <= 100)
var quantile = cdfForProbability[degreesOfFreedom - 1]; // The first entry is for the one degree of freedom.
else if (degreesOfFreedom <= 300)
var quantile = cdfForProbability[Math.round(degreesOfFreedom / 10) + 100 - 10 - 1];
else if (degreesOfFreedom <= 1300)
var quantile = cdfForProbability[Math.round(degreesOfFreedom / 100) + 120 - 3 - 1];
else
var quantile = cdfForProbability[cdfForProbability.length - 1];
return quantile * this.sampleStandardDeviation(numberOfSamples, sum, squareSum) / Math.sqrt(numberOfSamples);
}
this.confidenceInterval = function (values, probability) {
var sum = this.sum(values);
var mean = sum / values.length;
var delta = this.confidenceIntervalDelta(probability || 0.95, values.length, sum, this.squareSum(values));
return [mean - delta, mean + delta];
}
// See http://en.wikipedia.org/wiki/Student's_t-distribution#Table_of_selected_values
// This table contains one sided (a.k.a. tail) values.
// Use TINV((1 - probability) * 2, df) in your favorite spreadsheet software to compute these.
// The spacing of the values with df greater than 100 maintains error less than 0.8%.
var tDistributionInverseCDF = {
0.9: [
// 1 - 100 step 1
3.077684, 1.885618, 1.637744, 1.533206, 1.475884, 1.439756, 1.414924, 1.396815, 1.383029, 1.372184,
1.363430, 1.356217, 1.350171, 1.345030, 1.340606, 1.336757, 1.333379, 1.330391, 1.327728, 1.325341,
1.323188, 1.321237, 1.319460, 1.317836, 1.316345, 1.314972, 1.313703, 1.312527, 1.311434, 1.310415,
1.309464, 1.308573, 1.307737, 1.306952, 1.306212, 1.305514, 1.304854, 1.304230, 1.303639, 1.303077,
1.302543, 1.302035, 1.301552, 1.301090, 1.300649, 1.300228, 1.299825, 1.299439, 1.299069, 1.298714,
1.298373, 1.298045, 1.297730, 1.297426, 1.297134, 1.296853, 1.296581, 1.296319, 1.296066, 1.295821,
1.295585, 1.295356, 1.295134, 1.294920, 1.294712, 1.294511, 1.294315, 1.294126, 1.293942, 1.293763,
1.293589, 1.293421, 1.293256, 1.293097, 1.292941, 1.292790, 1.292643, 1.292500, 1.292360, 1.292224,
1.292091, 1.291961, 1.291835, 1.291711, 1.291591, 1.291473, 1.291358, 1.291246, 1.291136, 1.291029,
1.290924, 1.290821, 1.290721, 1.290623, 1.290527, 1.290432, 1.290340, 1.290250, 1.290161, 1.290075,
// 110 - 300 step 10
1.289295, 1.288646, 1.288098, 1.287628, 1.287221, 1.286865, 1.286551, 1.286272, 1.286023, 1.285799,
1.285596, 1.285411, 1.285243, 1.285089, 1.284947, 1.284816, 1.284695, 1.284582, 1.284478, 1.284380,
// 400 - 1300 step 100
1.283672, 1.283247, 1.282964, 1.282762, 1.282611, 1.282493, 1.282399, 1.282322, 1.282257, 1.282203,
// Infinity
1.281548],
0.95: [
// 1 - 100 step 1
6.313752, 2.919986, 2.353363, 2.131847, 2.015048, 1.943180, 1.894579, 1.859548, 1.833113, 1.812461,
1.795885, 1.782288, 1.770933, 1.761310, 1.753050, 1.745884, 1.739607, 1.734064, 1.729133, 1.724718,
1.720743, 1.717144, 1.713872, 1.710882, 1.708141, 1.705618, 1.703288, 1.701131, 1.699127, 1.697261,
1.695519, 1.693889, 1.692360, 1.690924, 1.689572, 1.688298, 1.687094, 1.685954, 1.684875, 1.683851,
1.682878, 1.681952, 1.681071, 1.680230, 1.679427, 1.678660, 1.677927, 1.677224, 1.676551, 1.675905,
1.675285, 1.674689, 1.674116, 1.673565, 1.673034, 1.672522, 1.672029, 1.671553, 1.671093, 1.670649,
1.670219, 1.669804, 1.669402, 1.669013, 1.668636, 1.668271, 1.667916, 1.667572, 1.667239, 1.666914,
1.666600, 1.666294, 1.665996, 1.665707, 1.665425, 1.665151, 1.664885, 1.664625, 1.664371, 1.664125,
1.663884, 1.663649, 1.663420, 1.663197, 1.662978, 1.662765, 1.662557, 1.662354, 1.662155, 1.661961,
1.661771, 1.661585, 1.661404, 1.661226, 1.661052, 1.660881, 1.660715, 1.660551, 1.660391, 1.660234,
// 110 - 300 step 10
1.658824, 1.657651, 1.656659, 1.655811, 1.655076, 1.654433, 1.653866, 1.653363, 1.652913, 1.652508,
1.652142, 1.651809, 1.651506, 1.651227, 1.650971, 1.650735, 1.650517, 1.650314, 1.650125, 1.649949,
// 400 - 1300 step 100
1.648672, 1.647907, 1.647397, 1.647033, 1.646761, 1.646548, 1.646379, 1.646240, 1.646124, 1.646027,
// Infinity
1.644847],
0.975: [
// 1 - 100 step 1
12.706205, 4.302653, 3.182446, 2.776445, 2.570582, 2.446912, 2.364624, 2.306004, 2.262157, 2.228139,
2.200985, 2.178813, 2.160369, 2.144787, 2.131450, 2.119905, 2.109816, 2.100922, 2.093024, 2.085963,
2.079614, 2.073873, 2.068658, 2.063899, 2.059539, 2.055529, 2.051831, 2.048407, 2.045230, 2.042272,
2.039513, 2.036933, 2.034515, 2.032245, 2.030108, 2.028094, 2.026192, 2.024394, 2.022691, 2.021075,
2.019541, 2.018082, 2.016692, 2.015368, 2.014103, 2.012896, 2.011741, 2.010635, 2.009575, 2.008559,
2.007584, 2.006647, 2.005746, 2.004879, 2.004045, 2.003241, 2.002465, 2.001717, 2.000995, 2.000298,
1.999624, 1.998972, 1.998341, 1.997730, 1.997138, 1.996564, 1.996008, 1.995469, 1.994945, 1.994437,
1.993943, 1.993464, 1.992997, 1.992543, 1.992102, 1.991673, 1.991254, 1.990847, 1.990450, 1.990063,
1.989686, 1.989319, 1.988960, 1.988610, 1.988268, 1.987934, 1.987608, 1.987290, 1.986979, 1.986675,
1.986377, 1.986086, 1.985802, 1.985523, 1.985251, 1.984984, 1.984723, 1.984467, 1.984217, 1.983972,
// 110 - 300 step 10
1.981765, 1.979930, 1.978380, 1.977054, 1.975905, 1.974902, 1.974017, 1.973231, 1.972528, 1.971896,
1.971325, 1.970806, 1.970332, 1.969898, 1.969498, 1.969130, 1.968789, 1.968472, 1.968178, 1.967903,
// 400 - 1300 step 100
1.965912, 1.964720, 1.963926, 1.963359, 1.962934, 1.962603, 1.962339, 1.962123, 1.961943, 1.961790,
// Infinity
1.959964],
0.99: [
// 1 - 100 step 1
31.820516, 6.964557, 4.540703, 3.746947, 3.364930, 3.142668, 2.997952, 2.896459, 2.821438, 2.763769,
2.718079, 2.680998, 2.650309, 2.624494, 2.602480, 2.583487, 2.566934, 2.552380, 2.539483, 2.527977,
2.517648, 2.508325, 2.499867, 2.492159, 2.485107, 2.478630, 2.472660, 2.467140, 2.462021, 2.457262,
2.452824, 2.448678, 2.444794, 2.441150, 2.437723, 2.434494, 2.431447, 2.428568, 2.425841, 2.423257,
2.420803, 2.418470, 2.416250, 2.414134, 2.412116, 2.410188, 2.408345, 2.406581, 2.404892, 2.403272,
2.401718, 2.400225, 2.398790, 2.397410, 2.396081, 2.394801, 2.393568, 2.392377, 2.391229, 2.390119,
2.389047, 2.388011, 2.387008, 2.386037, 2.385097, 2.384186, 2.383302, 2.382446, 2.381615, 2.380807,
2.380024, 2.379262, 2.378522, 2.377802, 2.377102, 2.376420, 2.375757, 2.375111, 2.374482, 2.373868,
2.373270, 2.372687, 2.372119, 2.371564, 2.371022, 2.370493, 2.369977, 2.369472, 2.368979, 2.368497,
2.368026, 2.367566, 2.367115, 2.366674, 2.366243, 2.365821, 2.365407, 2.365002, 2.364606, 2.364217,
// 110 - 300 step 10
2.360726, 2.357825, 2.355375, 2.353278, 2.351465, 2.349880, 2.348483, 2.347243, 2.346134, 2.345137,
2.344236, 2.343417, 2.342670, 2.341985, 2.341356, 2.340775, 2.340238, 2.339739, 2.339275, 2.338842,
// 400 - 1300 step 100
2.335706, 2.333829, 2.332579, 2.331687, 2.331018, 2.330498, 2.330083, 2.329743, 2.329459, 2.329220,
// Infinity
2.326348],
};
})();
if (typeof module != 'undefined') {
for (var key in Statistics)
module.exports[key] = Statistics[key];
}

View file

@ -0,0 +1,92 @@
// This file defines helper methods for running performance tests in workers.
(function () {
class WorkerTestHelper {
constructor() {
this.callsPerIteration = 1;
}
// Measure the runs per second of test.run().
// This method should be used together with
// |PerfTestRunner.startMeasureValuesInWorker| in
// src/third_party/blink/perf_tests/resources/runner.js.
//
// Arguments:
// |test.run| is the function to test.
// |test.setup| and |test.tearDown| are optional functions.
// |test.iterationCount| defines count of iterations to run. Default value
// is 5.
//
// Returns a promise that resolves to an object:
// |result.error|: The error string or null if no error occurs.
// |result.values|: An array of test result values. Unit is runs/s.
async measureRunsPerSecond(test) {
return await this.runTestRepeatedly_(test,
this.measureRunsPerSecondOnce_.bind(this));
}
// Measure the elapsed time of test.run().
// This method should be used together with
// |PerfTestRunner.startMeasureValuesInWorker| in
// src/third_party/blink/perf_tests/resources/runner.js.
//
// Refer measureRunsPerSecond() for definition of the arguments.
//
// Returns a promise that resolves to an object:
// |result.error|: The error string or null if no error occurs.
// |result.values|: An array of test result values. Unit is ms.
async measureTime(test) {
return await this.runTestRepeatedly_(test,
this.callRunAndMeasureTime_.bind(this));
}
// Repeatedly run test.run() and measure it.
async runTestRepeatedly_(test, proc) {
this.test = test;
const values = [];
const iterationCount =
this.test.iterationCount ? this.test.iterationCount : 5;
try {
if (this.test.setup)
await this.test.setup();
for (let i = 0; i < iterationCount; i++) {
values.push(await proc());
}
if (this.test.tearDown)
await this.test.tearDown();
} catch (exception) {
const error = "Got an exception while running test with name=" +
exception.name + ", message=" + exception.message + "\n" +
exception.stack;
return { error: error, values: null };
}
return { error: null, values: values };
}
// This method is basically the same with measureRunsPerSecondOnce() in
// src/third_party/blink/perf_tests/resources/runner.js
async measureRunsPerSecondOnce_() {
const timeToRun = 750;
let totalTime = 0;
let numberOfRuns = 0;
while (totalTime < timeToRun) {
totalTime += await this.callRunAndMeasureTime_();
numberOfRuns += this.callsPerIteration;
if (totalTime < 100)
this.callsPerIteration = Math.max(10, 2 * this.callsPerIteration);
}
return numberOfRuns * 1000 / totalTime;
};
async callRunAndMeasureTime_() {
const startTime = performance.now();
for (let i = 0; i < this.callsPerIteration; i++) {
await this.test.run();
}
return performance.now() - startTime;
}
}
self.workerTestHelper = new WorkerTestHelper();
})();