| OLD | NEW |
| 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 from telemetry.value import summary as summary_module |
| 5 | 6 |
| 6 class OutputFormatter(object): | 7 class OutputFormatter(object): |
| 7 """A formatter for PageTestResults. | 8 """A formatter for PageTestResults. |
| 8 | 9 |
| 9 An OutputFormatter takes PageTestResults, formats the results | 10 An OutputFormatter takes PageTestResults, formats the results |
| 10 (telemetry.value.Value instances), and output the formatted results | 11 (telemetry.value.Value instances), and output the formatted results |
| 11 in the given output stream. | 12 in the given output stream. |
| 12 | 13 |
| 13 Examples of output formatter: CsvOutputFormatter produces results in | 14 Examples of output formatter: CsvOutputFormatter produces results in |
| 14 CSV format.""" | 15 CSV format.""" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 28 | 29 |
| 29 Args: | 30 Args: |
| 30 page_test_results: A PageTestResults object containing all results | 31 page_test_results: A PageTestResults object containing all results |
| 31 from the current benchmark run. | 32 from the current benchmark run. |
| 32 """ | 33 """ |
| 33 raise NotImplementedError() | 34 raise NotImplementedError() |
| 34 | 35 |
| 35 @property | 36 @property |
| 36 def output_stream(self): | 37 def output_stream(self): |
| 37 return self._output_stream | 38 return self._output_stream |
| 39 |
| 40 |
| 41 def SummarizePageSpecificValues(page_specific_values): |
| 42 """Summarize results appropriately for TBM and legacy benchmarks. |
| 43 |
| 44 For benchmarks that are timeline-based, we need to summarize not once, but |
| 45 twice, once by name and tir_label (default) and again by name only. But for |
| 46 benchmarks that are not timeline-based, since no tir_labels are set, we will |
| 47 end up duplicating values. |
| 48 |
| 49 Thus, we only want to summarize once if the benchmark is not timeline-based, |
| 50 but twice, using the two different key functions, otherwise. |
| 51 """ |
| 52 # Default summary uses merge_values.DefaultKeyFunc to summarize both by name |
| 53 # and tir_label. |
| 54 summary = summary_module.Summary(page_specific_values) |
| 55 values = summary.interleaved_computed_per_page_values_and_summaries |
| 56 |
| 57 if any(v.tir_label for v in page_specific_values): |
| 58 summary_by_name_only = summary_module.Summary( |
| 59 page_specific_values, |
| 60 key_func=lambda v: v.name) |
| 61 values.extend( |
| 62 summary_by_name_only.interleaved_computed_per_page_values_and_summaries |
| 63 ) |
| 64 return values |
| OLD | NEW |