04bdbe8c1773c068a862ae8aa3129cb806084f6b
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / data / patches / JetStream.patch
1 diff --git a/JetStream/JetStream-1.0.1/JetStreamDriver.js b/JetStream/JetStream-1.0.1/JetStreamDriver.js
2 index 73ee420..60f587c 100644
3 --- a/JetStream/JetStream-1.0.1/JetStreamDriver.js
4 +++ b/JetStream/JetStream-1.0.1/JetStreamDriver.js
5 @@ -448,6 +448,14 @@ var JetStream = (function() {
6  
7          return rawResults;
8      }
9 +    
10 +    function computeRefinedResults(){
11 +        var results = {};
12 +        for (var i = 0; i < benchmarks.length; ++i) {
13 +            results[benchmarks[i].name] = {"metrics" : {"Score" : {"current" : [benchmarks[i].results]}}};
14 +        }
15 +        return {"JetStream": {"metrics" : {"Score" : ["Geometric"]}, "tests" : results}};
16 +    }
17  
18      function end()
19      {
20 @@ -458,6 +466,23 @@ var JetStream = (function() {
21          isRunning = false;
22          hasAlreadyRun = true;
23          prepareToStart();
24 +        // submit result to server
25 +        results = JSON.stringify(computeRefinedResults());
26 +        var xhr = new XMLHttpRequest();
27 +        xhr.open("POST", "/report");
28 +       
29 +        xhr.setRequestHeader("Content-type", "application/json");
30 +        xhr.setRequestHeader("Content-length", results.length);
31 +        xhr.setRequestHeader("Connection", "close");
32
33 +        xhr.onreadystatechange = function() {
34 +        if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
35 +                closeRequest = new XMLHttpRequest();
36 +                closeRequest.open("GET", "/shutdown");
37 +                closeRequest.send()
38 +            }
39 +        }
40 +        xhr.send(results);
41      }
42  
43      function iterate()
44 diff --git a/JetStream/JetStream-1.0.1/index.html b/JetStream/JetStream-1.0.1/index.html
45 index e27535c..001087d 100644
46 --- a/JetStream/JetStream-1.0.1/index.html
47 +++ b/JetStream/JetStream-1.0.1/index.html
48 @@ -34,8 +34,10 @@
49      window.onerror = function() { allIsGood = false; }
50  
51      function initialize() {
52 -        if (allIsGood)
53 +        if (allIsGood) {
54              JetStream.initialize();
55 +            setTimeout(function(){window.location = "javascript:JetStream.start()"}, 3000);
56 +        }
57          else
58              document.getElementById("body").innerHTML = "<h1>ERROR</h1><p>Encountered errors during page load. Refusing to run a partial benchmark suite.</p>";
59      }