[CSS Shapes] Add performance test for raster shape
[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         willStartFirstIteration: function (iterationCount) {
23             createTest = function (name, aggregator, isLastTest) {
24                 return {
25                     customIterationCount: iterationCount,
26                     doNotIgnoreInitialRun: true,
27                     doNotMeasureMemoryUsage: true,
28                     continueTesting: !isLastTest,
29                     unit: 'ms',
30                     name: name,
31                     aggregator: aggregator};
32             }
33             PerfTestRunner.prepareToMeasureValuesAsync(createTest(null, 'Total'));
34         },
35         didRunSuites: function (measuredValues) {
36             PerfTestRunner.measureValueAsync(measuredValues.total);
37             valuesByIteration.push(measuredValues.tests);
38         },
39         didFinishLastIteration: function () {
40             document.head.removeChild(document.querySelector('style'));
41
42             var measuredValuesByFullName = {};
43             function addToMeasuredValue(value, fullName, aggregator) {
44                 var values = measuredValuesByFullName[fullName] || new Array;
45                 measuredValuesByFullName[fullName] = values;
46                 values.push(value);
47                 values.aggregator = aggregator;
48             }
49
50             valuesByIteration.forEach(function (measuredValues) {
51                 for (var suiteName in measuredValues) {
52                     var suite = measuredValues[suiteName];
53                     for (var testName in suite.tests) {
54                         var test = suite.tests[testName];
55                         for (var subtestName in test.tests)
56                             addToMeasuredValue(test.tests[subtestName], suiteName + '/' + testName + '/' + subtestName);
57                         addToMeasuredValue(test.total, suiteName + '/' + testName, 'Total');
58                     }
59                     addToMeasuredValue(suite.total, suiteName, 'Total');
60                 }
61             });
62
63             var fullNames = new Array;
64             for (var fullName in measuredValuesByFullName)
65                 fullNames.push(fullName);
66
67             for (var i = 0; i < fullNames.length; i++) {
68                 var values = measuredValuesByFullName[fullNames[i]];
69                 PerfTestRunner.reportValues(createTest(fullNames[i], values.aggregator, i + 1 == fullNames.length), values);
70             }
71         }
72     };
73 })();