run-benchmark should support SunSpider, Kraken and Octane
[WebKit-https.git] / Tools / Scripts / webkitpy / benchmark_runner / data / patches / Octane.patch
1 diff --git a/base.js b/base.js
2 index 9d6e3de..cddf800
3 --- a/base.js
4 +++ b/base.js
5 @@ -167,7 +167,7 @@ BenchmarkSuite.RunSuites = function(runner, skipBenchmarks) {
6      if (runner.NotifyScore) {
7        var score = BenchmarkSuite.GeometricMean(BenchmarkSuite.scores);
8        var formatted = BenchmarkSuite.FormatScore(100 * score);
9 -      runner.NotifyScore(formatted);
10 +      runner.NotifyScore(formatted, 100 * score);
11      }
12    }
13    RunStep();
14 @@ -250,7 +250,7 @@ BenchmarkSuite.prototype.NotifyResult = function() {
15    BenchmarkSuite.scores.push(score);
16    if (this.runner.NotifyResult) {
17      var formatted = BenchmarkSuite.FormatScore(100 * score);
18 -    this.runner.NotifyResult(this.name, formatted);
19 +    this.runner.NotifyResult(this.name, formatted, 100 * score);
20    }
21    if (this.reference.length == 2) {
22      var meanLatency = BenchmarkSuite.GeometricMeanLatency(this.results);
23 @@ -259,7 +259,7 @@ BenchmarkSuite.prototype.NotifyResult = function() {
24        BenchmarkSuite.scores.push(scoreLatency);
25        if (this.runner.NotifyResult) {
26          var formattedLatency = BenchmarkSuite.FormatScore(100 * scoreLatency)
27 -        this.runner.NotifyResult(this.name + "Latency", formattedLatency);
28 +        this.runner.NotifyResult(this.name + "Latency", formattedLatency, 100 * scoreLatency);
29        }
30      }
31    }
32 index 77cbdfb..fe56fc4
33 --- a/index.html
34 +++ b/index.html
35 @@ -57,7 +57,9 @@
36      });
37    }
38  
39 -  function AddResult(name, result) {
40 +  var octaneSubtests = {};
41 +  function AddResult(name, result, rawScore) {
42 +    octaneSubtests[name] = {"metrics": {"Score": {"current": [rawScore]}}};
43      console.log(name + ': ' + result);
44      var box = document.getElementById("Result-" + name);
45      box.innerHTML = result;
46 @@ -75,7 +77,21 @@
47      success = false;
48    }
49  
50 -  function AddScore(score) {
51 +  function AddScore(score, rawScore) {
52 +    var results = JSON.stringify({"Octane": {"metrics": {"Score": {"current": [rawScore]}}, "tests": octaneSubtests}});
53 +    var xhr = new XMLHttpRequest();
54 +    xhr.open("POST", "/report");
55 +    xhr.setRequestHeader("Content-Type", "application/json");
56 +    xhr.setRequestHeader("Content-Length", results.length);
57 +    xhr.setRequestHeader("Connection", "close");
58 +    xhr.onreadystatechange = function() {
59 +    if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
60 +            closeRequest = new XMLHttpRequest();
61 +            closeRequest.open("GET", "/shutdown");
62 +            closeRequest.send();
63 +        }
64 +    }
65 +    xhr.send(results);
66      var status = document.getElementById("main-banner");
67      if (success) {
68        status.innerHTML = "Octane Score: " + score;