Index: scripts/slave/results_dashboard.py |
diff --git a/scripts/slave/results_dashboard.py b/scripts/slave/results_dashboard.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eebeccf4f0c08d3fac16a4e2caa3e930df2ee9ed |
--- /dev/null |
+++ b/scripts/slave/results_dashboard.py |
@@ -0,0 +1,66 @@ |
+#!/usr/bin/env python |
+# Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""Functions for adding results to perf dashboard.""" |
+ |
+import httplib |
+import json |
+import sys |
+import urllib |
+import urllib2 |
+ |
+SEND_RESULTS_PATH = "/add_point" |
+RESULTS_LINK_PATH = "/report?masters=%s&bots=%s&tests=%s&rev=%s" |
+ |
+ |
+# TODO(sullivan): cache results to a file in case of http errors. |
+def SendResults(logname, lines, system, test, url): |
+ results_to_add = [] |
+ # TODO(sullivan): Where to get the master (e.g. "ChromiumPerf") from? |
Mike Stip (use stip instead)
2013/02/21 23:12:49
I would pass this from the master to runtest.py as
|
+ master = "master" |
+ bot = system |
+ if not logname.endswith("-summary.dat"): |
+ return |
+ graph = logname.replace("-summary.dat", "") |
+ for line in lines: |
+ data = json.loads(line) |
+ # TODO(sullivan): This is the git rev. We want svn rev, for proper ordering. |
+ revision = data["rev"] |
+ for (trace, values) in data["traces"].iteritems(): |
+ # TODO(sullivan): Handle special trace names: |
+ # Reference builds |
+ # graph == trace (main graph) |
+ # by_url builds |
+ result = { |
+ "master": master, |
+ "bot": system, |
+ "test": "%s/%s/%s" % (test, graph, trace), |
+ "revision": revision, |
+ "value": values[0], |
+ "error": values[1], |
+ } |
+ # TODO(sullivan): webkit_rev is set to "undefined" here even when it is |
+ # available in the stdio. |
+ if "webkit_rev" in data and data["webkit_rev"] != "undefined": |
+ result["supplemental_columns"] = {"r_webkit_rev": data["webkit_rev"]} |
+ results_to_add.append(result) |
+ data = urllib.urlencode({"data": json.dumps(results_to_add)}) |
+ req = urllib2.Request(url + SEND_RESULTS_PATH, data) |
+ # TODO(sullivan): properly handle exceptions. |
+ try: |
+ urllib2.urlopen(req) |
+ except urllib2.HTTPError, e: |
+ sys.stderr.write("HTTPError: %d\n" % e.code) |
+ except urllib2.URLError, e: |
+ sys.stderr.write("URLError: %s\n", str(e.reason)) |
+ except httplib.HTTPException, e: |
+ sys.stderr.write("HTTPException\n") |
+ |
+ results_link = url + RESULTS_LINK_PATH % ( |
+ urllib.quote(master), |
+ urllib.quote(bot), |
+ urllib.quote(test + "/" + graph), |
+ revision) |
+ print "@@@STEP_LINK@%s@%s@@@" % ("Results Dashboard", results_link) |