run-benchmark should support SunSpider, Kraken and Octane
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / data / patches / Speedometer.patch
1 diff --git a/Full.html b/Full.html
2 index 419b9f2..0b04c69 100644
3 --- a/Full.html
4 +++ b/Full.html
5 @@ -7,7 +7,6 @@
6      <script src="resources/main.js" defer></script>
7      <script src="resources/benchmark-runner.js" defer></script>
8      <script src="resources/benchmark-report.js" defer></script>
9 -    <script src="../resources/statistics.js" defer></script>
10      <script src="resources/tests.js" defer></script>
11  </head>
12  <body>
13 diff --git a/resources/benchmark-report.js b/resources/benchmark-report.js
14 index c4b4c64..874f597 100644
15 --- a/resources/benchmark-report.js
16 +++ b/resources/benchmark-report.js
17 @@ -1,30 +1,26 @@
18  // This file can be customized to report results as needed.
19  
20  (function () {
21 -    if (!window.testRunner && location.search != '?webkit' && location.hash != '#webkit')
22 -        return;
23 -
24      if (window.testRunner)
25          testRunner.waitUntilDone();
26  
27 -    var scriptElement = document.createElement('script');
28 -    scriptElement.src = '../resources/runner.js';
29 -    document.head.appendChild(scriptElement);
30 -
31 -    var styleElement = document.createElement('style');
32 -    styleElement.textContent = 'pre { padding-top: 600px; }';
33 -    document.head.appendChild(styleElement);
34 -
35 +    showSection('running')
36      var createTest;
37      var valuesByIteration = new Array;
38 +    var timeValues = new Array;
39  
40      window.onload = function () {
41 -        document.body.removeChild(document.querySelector('main'));
42          startBenchmark();
43      }
44  
45      window.benchmarkClient = {
46          iterationCount: 5, // Use 4 different instances of DRT/WTR to run 5 iterations.
47 +        willAddTestFrame: function (frame) {
48 +            var main = document.querySelector('main');
49 +            var style = getComputedStyle(main);
50 +            frame.style.left = main.offsetLeft + parseInt(style.borderLeftWidth) + parseInt(style.paddingLeft) + 'px';
51 +            frame.style.top = main.offsetTop + parseInt(style.borderTopWidth) + parseInt(style.paddingTop) + 'px';
52 +        },
53          willStartFirstIteration: function (iterationCount) {
54              createTest = function (name, aggregator, isLastTest) {
55                  return {
56 @@ -36,15 +32,12 @@
57                      name: name,
58                      aggregator: aggregator};
59              }
60 -            PerfTestRunner.prepareToMeasureValuesAsync(createTest(null, 'Total'));
61          },
62          didRunSuites: function (measuredValues) {
63 -            PerfTestRunner.measureValueAsync(measuredValues.total);
64              valuesByIteration.push(measuredValues.tests);
65 +            timeValues.push(measuredValues.total);
66          },
67          didFinishLastIteration: function () {
68 -            document.head.removeChild(document.querySelector('style'));
69 -
70              var measuredValuesByFullName = {};
71              function addToMeasuredValue(value, fullName, aggregator) {
72                  var values = measuredValuesByFullName[fullName] || new Array;
73 @@ -52,19 +45,30 @@
74                  values.push(value);
75                  values.aggregator = aggregator;
76              }
77 -
78 +            var dict = {}
79 +            var scores= timeValues.map(computeScore);
80 +            function addToDictionaryValue(value, suiteName, testName, subtestName) {
81 +                dict["Speedometer"] = dict["Speedometer"] || { "metrics" : { "Time" : [ "Total", ], "Score": { "current" : [scores] } }, "tests" : {}};
82 +                dict["Speedometer"]["tests"][suiteName] = dict["Speedometer"]["tests"][suiteName] || {"metrics" : { "Time" : [ "Total", ] }, "tests" : {}};
83 +                dict["Speedometer"]["tests"][suiteName]["tests"][testName] = dict["Speedometer"]["tests"][suiteName]["tests"][testName] || { "metrics" : { "Time" : [ "Total", ] }, "tests" : {}};
84 +                dict["Speedometer"]["tests"][suiteName]["tests"][testName]["tests"][subtestName] = dict["Speedometer"]["tests"][suiteName]["tests"][testName]["tests"][subtestName] || { "metrics" : { "Time" : { "current" : [[]] } }};
85 +                dict["Speedometer"]["tests"][suiteName]["tests"][testName]["tests"][subtestName]["metrics"]["Time"]["current"][0].push(value);
86 +            }
87              valuesByIteration.forEach(function (measuredValues) {
88                  for (var suiteName in measuredValues) {
89                      var suite = measuredValues[suiteName];
90                      for (var testName in suite.tests) {
91                          var test = suite.tests[testName];
92 -                        for (var subtestName in test.tests)
93 +                        for (var subtestName in test.tests) {
94                              addToMeasuredValue(test.tests[subtestName], suiteName + '/' + testName + '/' + subtestName);
95 +                            addToDictionaryValue(test.tests[subtestName], suiteName, testName, subtestName);
96 +                        }
97                          addToMeasuredValue(test.total, suiteName + '/' + testName, 'Total');
98                      }
99                      addToMeasuredValue(suite.total, suiteName, 'Total');
100                  }
101              });
102 +            var results = JSON.stringify(dict);
103  
104              var fullNames = new Array;
105              for (var fullName in measuredValuesByFullName)
106 @@ -72,8 +76,22 @@
107  
108              for (var i = 0; i < fullNames.length; i++) {
109                  var values = measuredValuesByFullName[fullNames[i]];
110 -                PerfTestRunner.reportValues(createTest(fullNames[i], values.aggregator, i + 1 == fullNames.length), values);
111              }
112 +            var xhr = new XMLHttpRequest();
113 +            xhr.open("POST", "/report");
114 +
115 +            xhr.setRequestHeader("Content-type", "application/json");
116 +            xhr.setRequestHeader("Content-length", results.length);
117 +            xhr.setRequestHeader("Connection", "close");
118 +
119 +            xhr.onreadystatechange = function() {
120 +                if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
121 +                    var closeRequest = new XMLHttpRequest();
122 +                    closeRequest.open("GET", "/shutdown");
123 +                    closeRequest.send()
124 +                }
125 +            }
126 +            xhr.send(results);
127          }
128      };
129  })();