f7424e5b5436c5394209e6ab3bebf6a824b2ba65
[WebKit-https.git] / PerformanceTests / DoYouEvenBench / resources / benchmark-report.js
1 // This file can be customized to report results as needed.
2
3 (function () {
4     if (!window.testRunner && location.search != '?webkit' && location.hash != '#webkit')
5         return;
6
7     if (window.testRunner)
8         testRunner.waitUntilDone();
9
10     var scriptElement = document.createElement('script');
11     scriptElement.src = '../resources/runner.js';
12     document.head.appendChild(scriptElement);
13
14     var styleElement = document.createElement('style');
15     styleElement.textContent = 'pre { padding-top: 600px; }';
16     document.head.appendChild(styleElement);
17
18     var createTest;
19     var valuesByIteration = new Array;
20
21     window.benchmarkClient = {
22         iterationCount: 5, // Use 4 different instances of DRT/WTR to run 5 iterations.
23         willStartFirstIteration: function (iterationCount) {
24             createTest = function (name, aggregator, isLastTest) {
25                 return {
26                     customIterationCount: iterationCount,
27                     doNotIgnoreInitialRun: true,
28                     doNotMeasureMemoryUsage: true,
29                     continueTesting: !isLastTest,
30                     unit: 'ms',
31                     name: name,
32                     aggregator: aggregator};
33             }
34             PerfTestRunner.prepareToMeasureValuesAsync(createTest(null, 'Total'));
35         },
36         didRunSuites: function (measuredValues) {
37             PerfTestRunner.measureValueAsync(measuredValues.total);
38             valuesByIteration.push(measuredValues.tests);
39         },
40         didFinishLastIteration: function () {
41             document.head.removeChild(document.querySelector('style'));
42
43             var measuredValuesByFullName = {};
44             function addToMeasuredValue(value, fullName, aggregator) {
45                 var values = measuredValuesByFullName[fullName] || new Array;
46                 measuredValuesByFullName[fullName] = values;
47                 values.push(value);
48                 values.aggregator = aggregator;
49             }
50
51             valuesByIteration.forEach(function (measuredValues) {
52                 for (var suiteName in measuredValues) {
53                     var suite = measuredValues[suiteName];
54                     for (var testName in suite.tests) {
55                         var test = suite.tests[testName];
56                         for (var subtestName in test.tests)
57                             addToMeasuredValue(test.tests[subtestName], suiteName + '/' + testName + '/' + subtestName);
58                         addToMeasuredValue(test.total, suiteName + '/' + testName, 'Total');
59                     }
60                     addToMeasuredValue(suite.total, suiteName, 'Total');
61                 }
62             });
63
64             var fullNames = new Array;
65             for (var fullName in measuredValuesByFullName)
66                 fullNames.push(fullName);
67
68             for (var i = 0; i < fullNames.length; i++) {
69                 var values = measuredValuesByFullName[fullNames[i]];
70                 PerfTestRunner.reportValues(createTest(fullNames[i], values.aggregator, i + 1 == fullNames.length), values);
71             }
72         }
73     };
74 })();