Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from telemetry.value import summary as summary_module | |
| 6 | |
| 7 def ResultsAsChartDict(page_specific_values, summary_values, metadata): | |
|
chrishenry - DO NOT USE
2014/08/13 05:12:01
s/metadata/benchmark_metadata/ (metadata is too ge
chrishenry - DO NOT USE
2014/08/13 05:12:01
This isn't really a "value" but more a summary of
chrishenry - DO NOT USE
2014/08/13 05:12:01
Why does this take page_specific_values and summar
eakuefner
2014/08/15 22:47:31
You're right that there isn't a really clear conce
eakuefner
2014/08/15 22:47:32
We leave that up to the caller; this makes testing
eakuefner
2014/08/15 22:47:32
Done.
chrishenry
2014/08/19 17:36:21
If you need a unit test equivalent, please create
eakuefner
2014/08/21 01:11:17
Eventually we want to make Chart JSON actually a t
| |
| 8 """Produces a dict for serialization to Chart JSON format from raw values. | |
| 9 | |
| 10 Chart JSON is a transformation of the basic Telemetry JSON format that | |
|
chrishenry - DO NOT USE
2014/08/13 05:12:02
This should doc the schema as well or point to doc
eakuefner
2014/08/15 22:47:32
Done.
| |
| 11 removes the page map, summarizes the raw values, and organizes the results | |
| 12 by chart and trace name. This function takes the key pieces of data needed to | |
| 13 perform this transformation (namely, lists of values and a benchmark metadata | |
| 14 object) and processes them into a dict which can be serialized using the json | |
| 15 module. | |
| 16 | |
| 17 page_specific_values: list of all values with an associated page | |
| 18 summary_values: list of all values without an associated page | |
| 19 metadata: a benchmark.BenchmarkMetadata object | |
| 20 """ | |
|
nednguyen
2014/08/13 02:17:03
Assert summary_values contains "all values without
eakuefner
2014/08/15 22:47:31
We want this invariant to be enforced higher up th
| |
| 21 # had_failures = len(page_test_results.failures) > 0 | |
|
nduca
2014/08/13 00:55:39
funky?
eakuefner
2014/08/13 01:03:43
Will decide on failure handling best effort & fix
| |
| 22 had_failures = False | |
| 23 summary = summary_module.Summary(page_specific_values, had_failures) | |
| 24 charts = {} | |
| 25 | |
| 26 _HandleComputedValues(summary, charts) | |
| 27 _HandleSummaryValues(summary_values, charts) | |
| 28 | |
| 29 result_dict = { | |
| 30 'format_version': '0.1', | |
| 31 'test_name': metadata.name, | |
| 32 'charts': charts | |
| 33 } | |
| 34 | |
| 35 return result_dict | |
| 36 | |
| 37 def _HandleComputedValues(summary, charts): | |
|
chrishenry - DO NOT USE
2014/08/13 05:12:01
Best if we can have this yield chart_name, chart_c
eakuefner
2014/08/15 22:47:32
This style matches the way we are handling results
| |
| 38 """Organizes computed per-page and summary values into a charts dict. | |
| 39 | |
| 40 summary: summary.Summary object containing computed values | |
| 41 charts: dict into which chartified values will be inserted | |
| 42 """ | |
| 43 | |
| 44 for value in summary.interleaved_computed_per_page_values_and_summaries: | |
| 45 if value.page: | |
| 46 chart_name, trace_name = ( | |
| 47 value.GetChartAndTraceNameForPerPageResult()) | |
| 48 else: | |
| 49 chart_name, trace_name = ( | |
| 50 value.GetChartAndTraceNameForComputedSummaryResult( | |
| 51 None)) | |
|
chrishenry - DO NOT USE
2014/08/13 05:12:01
nit: can fit in 80-col?
eakuefner
2014/08/15 22:47:31
Done.
| |
| 52 if chart_name == trace_name: | |
| 53 if chart_name in charts: | |
| 54 assert 'summary' not in charts[chart_name] | |
| 55 trace_name = 'summary' | |
| 56 | |
| 57 if chart_name in charts: | |
| 58 charts[chart_name]['traces'][trace_name] = value | |
|
chrishenry - DO NOT USE
2014/08/13 05:12:01
A little odd, can you document this briefly? Do al
eakuefner
2014/08/15 22:47:31
Added a couple comments to attempt to explain -- t
| |
| 59 else: | |
| 60 charts[chart_name] = { | |
| 61 'traces': {trace_name: value.AsDict()} | |
| 62 } | |
| 63 | |
| 64 def _HandleSummaryValues(summary_values, charts): | |
| 65 """Organizes summary values into a charts dict. | |
| 66 | |
| 67 While summary values can be created by a Summary object, they can also be | |
| 68 added directly during the course of a page run. Those values are not subject | |
| 69 to summarization and thus we handle them directly in this routine. | |
| 70 | |
| 71 page_test_results: a PageTestResults object containing overall values | |
|
chrishenry - DO NOT USE
2014/08/13 05:12:01
Outdated doc.
eakuefner
2014/08/15 22:47:32
Done.
| |
| 72 charts: dict into which chartified values will be inserted | |
| 73 """ | |
| 74 | |
| 75 # If any pages failed, we want to invalidate the overall results | |
| 76 # TODO(eakuefner): figure out how to handle this correctly | |
| 77 had_failures = False | |
| 78 if had_failures: | |
| 79 return | |
| 80 | |
| 81 for value in summary_values: | |
| 82 chart_name, trace_name = ( | |
| 83 value.GetChartAndTraceNameForComputedSummaryResult( | |
| 84 None)) | |
| 85 if chart_name == trace_name: | |
| 86 trace_name = 'summary' | |
| 87 if chart_name in charts: | |
| 88 assert trace_name not in charts[chart_name] | |
| 89 charts[chart_name][trace_name] = value | |
|
chrishenry - DO NOT USE
2014/08/13 05:12:01
value.AsDict()?
eakuefner
2014/08/15 22:47:32
Done.
| |
| 90 else: | |
| 91 charts[chart_name] = { | |
| 92 'units': value.units, | |
| 93 'traces': {trace_name: value.AsDict()} | |
| 94 } | |
| OLD | NEW |