diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /third_party/webkit/PerformanceTests/Speedometer/resources/benchmark-report.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/benchmark-report.js')
-rw-r--r-- | third_party/webkit/PerformanceTests/Speedometer/resources/benchmark-report.js | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/benchmark-report.js b/third_party/webkit/PerformanceTests/Speedometer/resources/benchmark-report.js new file mode 100644 index 0000000000..972fbb0529 --- /dev/null +++ b/third_party/webkit/PerformanceTests/Speedometer/resources/benchmark-report.js @@ -0,0 +1,105 @@ +// This file can be customized to report results as needed. + +(function () { + if ((!window.testRunner && location.search != '?webkit' && location.hash != '#webkit') + && location.search != '?gecko' && location.search != '?raptor') + return; + + if (window.testRunner) + testRunner.waitUntilDone(); + + var scriptElement = document.createElement('script'); + scriptElement.src = '../resources/runner.js'; + document.head.appendChild(scriptElement); + + var styleElement = document.createElement('style'); + styleElement.textContent = 'pre { padding-top: 600px; }'; + document.head.appendChild(styleElement); + + var createTest; + var valuesByIteration = new Array; + + window.onload = function () { + document.body.removeChild(document.querySelector('main')); + startBenchmark(); + } + + window.benchmarkClient = { + iterationCount: 5, // Use 4 different instances of DRT/WTR to run 5 iterations. + willStartFirstIteration: function (iterationCount) { + createTest = function (name, aggregator, isLastTest) { + return { + customIterationCount: iterationCount, + doNotIgnoreInitialRun: true, + doNotMeasureMemoryUsage: true, + continueTesting: !isLastTest, + unit: 'ms', + name: name, + aggregator: aggregator}; + } + if (window.PerfTestRunner) { + PerfTestRunner.prepareToMeasureValuesAsync(createTest(null, 'Total')); + } + }, + didRunSuites: function (measuredValues) { + if (window.PerfTestRunner) + PerfTestRunner.measureValueAsync(measuredValues.total); + valuesByIteration.push(measuredValues.tests); + }, + didFinishLastIteration: function () { + document.head.removeChild(document.querySelector('style')); + + var measuredValuesByFullName = {}; + function addToMeasuredValue(value, fullName, aggregator) { + var values = measuredValuesByFullName[fullName] || new Array; + measuredValuesByFullName[fullName] = values; + values.push(value); + values.aggregator = aggregator; + } + + valuesByIteration.forEach(function (measuredValues) { + for (var suiteName in measuredValues) { + var suite = measuredValues[suiteName]; + for (var testName in suite.tests) { + var test = suite.tests[testName]; + for (var subtestName in test.tests) + addToMeasuredValue(test.tests[subtestName], suiteName + '/' + testName + '/' + subtestName); + addToMeasuredValue(test.total, suiteName + '/' + testName, 'Total'); + } + addToMeasuredValue(suite.total, suiteName, 'Total'); + } + }); + + var fullNames = new Array; + for (var fullName in measuredValuesByFullName) { + fullNames.push(fullName); + } + + if (typeof tpRecordTime !== "undefined" || location.search == '?raptor') { + var values = new Array; + var allNames = new Array; + for (var i = 0; i < fullNames.length; i++) { + vals = measuredValuesByFullName[fullNames[i]]; + values.push(vals); + for (var count=0; count < vals.length; count ++) { + allNames.push(fullNames[i]); + } + } + + if (location.search == '?raptor') { + _data = ['raptor-benchmark', 'speedometer', measuredValuesByFullName]; + console.log('speedometer source about to post results to the raptor webext'); + window.postMessage(_data, '*'); + window.sessionStorage.setItem('benchmark_results', JSON.stringify(_data)); + } else { + tpRecordTime(values.join(','), 0, allNames.join(',')); + } + } else { + for (var i = 0; i < fullNames.length; i++) { + var values = measuredValuesByFullName[fullNames[i]]; + PerfTestRunner.reportValues(createTest(fullNames[i], values.aggregator, i + 1 == fullNames.length), values); + } + } + } + }; +})(); |