Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1532)

Unified Diff: mojo/devtools/common/devtoolslib/perf_dashboard.py

Issue 1412113003: mojo_benchmark: improve recording the chart data for perf dashboard. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address Etienne's comments. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/devtools/common/devtoolslib/perf_dashboard_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/perf_dashboard.py
diff --git a/mojo/devtools/common/devtoolslib/perf_dashboard.py b/mojo/devtools/common/devtoolslib/perf_dashboard.py
index aa11ff687b7e355e5954202dfcbc536cb331ed4d..74eb8cabdc0d448528c227e921303e2d0d5e9a0e 100644
--- a/mojo/devtools/common/devtoolslib/perf_dashboard.py
+++ b/mojo/devtools/common/devtoolslib/perf_dashboard.py
@@ -13,14 +13,16 @@ See http://www.chromium.org/developers/speed-infra/performance-dashboard/sending
import json
from collections import defaultdict
+
class ChartDataRecorder(object):
"""Allows one to record measurement values one by one and then generate the
JSON string that represents them in the 'chart_data' format expected by the
performance dashboard.
"""
- def __init__(self):
+ def __init__(self, benchmark_name):
self.charts = defaultdict(list)
+ self.benchmark_name = benchmark_name
def record_scalar(self, chart_name, value_name, units, value):
"""Records a single measurement value of a scalar type."""
@@ -31,5 +33,11 @@ class ChartDataRecorder(object):
'value': value})
def get_json(self):
- """Returns the JSON string representing the recorded chart data."""
- return json.dumps(self.charts)
+ """Returns the JSON string representing the recorded chart data, wrapping
+ it with the required meta data."""
+ chart_data = {
+ 'format_version': '1.0',
+ 'benchmark_name': self.benchmark_name,
+ 'charts': self.charts
+ }
+ return json.dumps(chart_data)
« no previous file with comments | « no previous file | mojo/devtools/common/devtoolslib/perf_dashboard_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698