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

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

Issue 1406063002: Teach mojo_benchmark to produce chart_data for the perf dashboard. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..aa11ff687b7e355e5954202dfcbc536cb331ed4d
--- /dev/null
+++ b/mojo/devtools/common/devtoolslib/perf_dashboard.py
@@ -0,0 +1,35 @@
+# Copyright 2015 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.
+
+# Disable the line-too-long warning.
+# pylint: disable=C0301
+"""This module implements the Chromium Performance Dashboard JSON v1.0 data
+format.
+
+See http://www.chromium.org/developers/speed-infra/performance-dashboard/sending-data-to-the-performance-dashboard.
+"""
+
+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):
+ self.charts = defaultdict(list)
+
+ def record_scalar(self, chart_name, value_name, units, value):
+ """Records a single measurement value of a scalar type."""
+ self.charts[chart_name].append({
+ 'type': 'scalar',
+ 'name': value_name,
+ 'units': units,
+ 'value': value})
+
+ def get_json(self):
+ """Returns the JSON string representing the recorded chart data."""
+ return json.dumps(self.charts)

Powered by Google App Engine
This is Rietveld 408576698