1b5f6352f3e1ece1321eeba7d373c63af0810c94
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / data / patches / Animometer.patch
1 diff --git a/runner/resources/animometer.js b/runner/resources/animometer.js
2 index e567681..ba0ab0f 100644
3 --- a/runner/resources/animometer.js
4 +++ b/runner/resources/animometer.js
5 @@ -41,14 +41,62 @@ window.benchmarkRunnerClient = {
6          this._resultsDashboard.push(suitesSamplers);
7      },
8      
9 +    _computeTestReport: function(testName, testResults)
10 +    {
11 +        return [testResults[Strings["JSON_SCORE"][0]]];
12 +    },
13 +
14 +    _computeSuiteReports: function(suiteName, suiteResults)
15 +    {
16 +        var testsReports = {};
17 +
18 +        for (var testName in suiteResults[Strings["JSON_RESULTS"][2]]) {
19 +            var testReports = this._computeTestReport(testName, suiteResults[Strings["JSON_RESULTS"][2]][testName]);
20 +            testsReports[testName] = { "metrics": { "Score": { "current": testReports } } };
21 +        }
22 +
23 +        return testsReports;
24 +    },
25 +
26 +    _computeIterationReports: function(iterationResults)
27 +    {
28 +        var suitesReports = {};
29 +
30 +        for (var suiteName in iterationResults[Strings["JSON_RESULTS"][1]]) {
31 +            var testsReports = this._computeSuiteReports(suiteName, iterationResults[Strings["JSON_RESULTS"][1]][suiteName]);
32 +            suitesReports[suiteName] = { "metrics": { "Score": ["Geometric"] }, "tests": testsReports };
33 +        }
34 +
35 +        return suitesReports;
36 +    },
37 +
38 +    computeResultsReports: function()
39 +    {
40 +        var json = this._resultsDashboard.toJSON(false, false);
41 +        var iterationReports = this._computeIterationReports(json[Strings["JSON_RESULTS"][0]][0])
42 +        return {"Animometer": {"metrics" : {"Score" : ["Geometric"]}, "tests" : iterationReports } };
43 +    },
44 +
45      didFinishLastIteration: function ()
46      {
47 -        var json = this._resultsDashboard.toJSON(true, true);
48 -        this.score = json[Strings["JSON_SCORE"]];
49 -        this._resultsTable.showIterations(json[Strings["JSON_RESULTS"][0]]);
50 -        sectionsManager.showJSON("json", json[Strings["JSON_RESULTS"][0]][0]);
51 -        suitesManager.updateLocalStorageFromJSON(json[Strings["JSON_RESULTS"][0]][0]);
52 -        benchmarkController.showResults();
53 +        // submit result to server
54 +        var results = JSON.stringify(this.computeResultsReports());
55 +        var xhr = new XMLHttpRequest();
56 +        xhr.open("POST", "/report");
57 +
58 +        xhr.setRequestHeader("Content-type", "application/json");
59 +        xhr.setRequestHeader("Content-length", results.length);
60 +        xhr.setRequestHeader("Connection", "close");
61 +
62 +        xhr.onreadystatechange = function() {
63 +            if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
64 +                closeRequest = new XMLHttpRequest();
65 +                closeRequest.open("GET", "/shutdown");
66 +                closeRequest.send()
67 +            }
68 +        }
69 +
70 +        xhr.send(results);
71      }
72  }
73  
74 @@ -307,6 +355,10 @@ window.suitesManager =
75  
76              suite.tests.forEach(function(test) {
77                  var testElement = this._createTestElement(listElement, test, suiteCheckbox);
78 +                if (index < 4) {
79 +                    var testCheckbox = this._checkboxElement(testElement);
80 +                    testCheckbox.checked = true;
81 +                }
82              }, this);
83          }, this);
84      },
85 @@ -408,10 +460,8 @@ window.benchmarkController =
86      initialize: function()
87      {
88          sectionsManager.setupSectionStyle();
89 -        optionsManager.updateUIFromLocalStorage();
90          suitesManager.createElements();
91 -        suitesManager.updateUIFromLocalStorage();
92 -        suitesManager.updateEditsElementsState();
93 +        setTimeout(this.startTest.bind(this), 3000);
94      },
95  
96      onChangeAdaptiveTestCheckbox: function()