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

Side by Side Diff: tools/telemetry/telemetry/results/chart_json_output_formatter.py

Issue 551063005: [Telemetry] Fix handling for two-part per-page value names in Chart JSON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 | tools/telemetry/telemetry/results/chart_json_output_formatter_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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 import collections 5 import collections
6 import itertools 6 import itertools
7 import json 7 import json
8 8
9 from telemetry.results import output_formatter 9 from telemetry.results import output_formatter
10 from telemetry.value import summary as summary_module 10 from telemetry.value import summary as summary_module
(...skipping 20 matching lines...) Expand all
31 A Chart JSON dict corresponding to the given data. 31 A Chart JSON dict corresponding to the given data.
32 """ 32 """
33 summary = summary_module.Summary(page_specific_values) 33 summary = summary_module.Summary(page_specific_values)
34 values = itertools.chain( 34 values = itertools.chain(
35 summary.interleaved_computed_per_page_values_and_summaries, 35 summary.interleaved_computed_per_page_values_and_summaries,
36 summary_values) 36 summary_values)
37 charts = collections.defaultdict(dict) 37 charts = collections.defaultdict(dict)
38 38
39 for value in values: 39 for value in values:
40 if value.page: 40 if value.page:
41 chart_name, trace_name = ( 41 chart_name, trace_name = (value.GetChartAndTraceNameForPerPageResult())
42 value.GetChartAndTraceNameForPerPageResult())
43 else: 42 else:
44 chart_name, trace_name = ( 43 chart_name, trace_name = (
45 value.GetChartAndTraceNameForComputedSummaryResult(None)) 44 value.GetChartAndTraceNameForComputedSummaryResult(None))
46 if chart_name == trace_name: 45 if chart_name == trace_name:
47 trace_name = 'summary' 46 trace_name = 'summary'
48 47
49 assert trace_name not in charts[chart_name] 48 # This intentionally overwrites the trace if it already exists because this
50 49 # is expected of output from the buildbots currently.
50 # See: crbug.com/413393
51 charts[chart_name][trace_name] = value.AsDict() 51 charts[chart_name][trace_name] = value.AsDict()
52 52
53 result_dict = { 53 result_dict = {
54 'format_version': '0.1', 54 'format_version': '0.1',
55 'benchmark_name': benchmark_metadata.name, 55 'benchmark_name': benchmark_metadata.name,
56 'charts': charts 56 'charts': charts
57 } 57 }
58 58
59 return result_dict 59 return result_dict
60 60
61 # TODO(eakuefner): Transition this to translate Telemetry JSON. 61 # TODO(eakuefner): Transition this to translate Telemetry JSON.
62 class ChartJsonOutputFormatter(output_formatter.OutputFormatter): 62 class ChartJsonOutputFormatter(output_formatter.OutputFormatter):
63 def __init__(self, output_stream, benchmark_metadata): 63 def __init__(self, output_stream, benchmark_metadata):
64 super(ChartJsonOutputFormatter, self).__init__(output_stream) 64 super(ChartJsonOutputFormatter, self).__init__(output_stream)
65 self._benchmark_metadata = benchmark_metadata 65 self._benchmark_metadata = benchmark_metadata
66 66
67 def Format(self, page_test_results): 67 def Format(self, page_test_results):
68 json.dump(_ResultsAsChartDict( 68 json.dump(_ResultsAsChartDict(
69 self._benchmark_metadata, 69 self._benchmark_metadata,
70 page_test_results.all_page_specific_values, 70 page_test_results.all_page_specific_values,
71 page_test_results.all_summary_values), 71 page_test_results.all_summary_values),
72 self.output_stream) 72 self.output_stream)
73 self.output_stream.write('\n') 73 self.output_stream.write('\n')
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/results/chart_json_output_formatter_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698