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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/devtools/common/devtoolslib/perf_dashboard_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Disable the line-too-long warning. 5 # Disable the line-too-long warning.
6 # pylint: disable=C0301 6 # pylint: disable=C0301
7 """This module implements the Chromium Performance Dashboard JSON v1.0 data 7 """This module implements the Chromium Performance Dashboard JSON v1.0 data
8 format. 8 format.
9 9
10 See http://www.chromium.org/developers/speed-infra/performance-dashboard/sending -data-to-the-performance-dashboard. 10 See http://www.chromium.org/developers/speed-infra/performance-dashboard/sending -data-to-the-performance-dashboard.
11 """ 11 """
12 12
13 import json 13 import json
14 from collections import defaultdict 14 from collections import defaultdict
15 15
16
16 class ChartDataRecorder(object): 17 class ChartDataRecorder(object):
17 """Allows one to record measurement values one by one and then generate the 18 """Allows one to record measurement values one by one and then generate the
18 JSON string that represents them in the 'chart_data' format expected by the 19 JSON string that represents them in the 'chart_data' format expected by the
19 performance dashboard. 20 performance dashboard.
20 """ 21 """
21 22
22 def __init__(self): 23 def __init__(self, benchmark_name):
23 self.charts = defaultdict(list) 24 self.charts = defaultdict(list)
25 self.benchmark_name = benchmark_name
24 26
25 def record_scalar(self, chart_name, value_name, units, value): 27 def record_scalar(self, chart_name, value_name, units, value):
26 """Records a single measurement value of a scalar type.""" 28 """Records a single measurement value of a scalar type."""
27 self.charts[chart_name].append({ 29 self.charts[chart_name].append({
28 'type': 'scalar', 30 'type': 'scalar',
29 'name': value_name, 31 'name': value_name,
30 'units': units, 32 'units': units,
31 'value': value}) 33 'value': value})
32 34
33 def get_json(self): 35 def get_json(self):
34 """Returns the JSON string representing the recorded chart data.""" 36 """Returns the JSON string representing the recorded chart data, wrapping
35 return json.dumps(self.charts) 37 it with the required meta data."""
38 chart_data = {
39 'format_version': '1.0',
40 'benchmark_name': self.benchmark_name,
41 'charts': self.charts
42 }
43 return json.dumps(chart_data)
OLDNEW
« 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