run-benchmark should support SunSpider, Kraken and Octane
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / data / patches / SunSpider.patch
1 diff --git a/hosted/sunspider-1.0.1/driver.html b/hosted/sunspider-1.0.1/driver.html
2 index 0700bb2..2dde01a 100644
3 --- a/hosted/sunspider-1.0.1/driver.html
4 +++ b/hosted/sunspider-1.0.1/driver.html
5 @@ -103,23 +103,28 @@ function recordResult(time)
6  
7  function finish()
8  {
9 -    var outputString = "{";
10 -    outputString += '"v": "sunspider-1.0.1", ';
11 +    var tests = {};
12      for (var test in output[0]) {
13 -        outputString += '"' + test + '":[';
14 -        for (var i = 0; i < output.length; i++) {
15 -            var time = output[i][test];
16 -            if (time != time)
17 -                time = "\"NaN\"";
18 -            outputString += time + ",";
19 -        }
20 -        outputString = outputString.substring(0, outputString.length - 1);
21 -        outputString += "],";
22 +        var values = new Array(output.length);
23 +        for (var i = 0; i < output.length; i++)
24 +            values[i] = output[i][test];
25 +        tests[test] = {"metrics": {"Time": {"current": [values]}}}
26      }
27 -    outputString = outputString.substring(0, outputString.length - 1);
28 -    outputString += "}";
29  
30 -    location = "results.html?" + encodeURI(outputString);
31 +    var results = JSON.stringify({"SunSpider": {"metrics": {"Time": ["Total"]}, "tests": tests}});
32 +    var xhr = new XMLHttpRequest();
33 +    xhr.open("POST", "/report");
34 +    xhr.setRequestHeader("Content-Type", "application/json");
35 +    xhr.setRequestHeader("Content-Length", results.length);
36 +    xhr.setRequestHeader("Connection", "close");
37 +    xhr.onreadystatechange = function() {
38 +    if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
39 +            closeRequest = new XMLHttpRequest();
40 +            closeRequest.open("GET", "/shutdown");
41 +            closeRequest.send();
42 +        }
43 +    }
44 +    xhr.send(results);
45  }
46  
47  </script>