Chromium Code Reviews| 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 collections import defaultdict | 5 from collections import defaultdict |
| 6 | 6 |
| 7 from telemetry.value import failure | 7 from telemetry.value import failure |
| 8 from telemetry.value import merge_values | 8 from telemetry.value import merge_values |
| 9 from telemetry.value import skip | 9 from telemetry.value import skip |
| 10 from telemetry.value import summarizable | |
| 10 | 11 |
| 11 | 12 |
| 12 class Summary(object): | 13 class Summary(object): |
| 13 """Computes summary values from the per-page-run values produced by a test. | 14 """Computes summary values from the per-page-run values produced by a test. |
| 14 | 15 |
| 15 Some telemetry benchmark repeat a number of times in order to get a reliable | 16 Some telemetry benchmark repeat a number of times in order to get a reliable |
| 16 measurement. The test does not have to handle merging of these runs: | 17 measurement. The test does not have to handle merging of these runs: |
| 17 summarizer does it for you. | 18 summarizer does it for you. |
| 18 | 19 |
| 19 For instance, if two pages run, 3 and 1 time respectively: | 20 For instance, if two pages run, 3 and 1 time respectively: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 values, then summary values. | 61 values, then summary values. |
| 61 | 62 |
| 62 """ | 63 """ |
| 63 return self._interleaved_computed_per_page_values_and_summaries | 64 return self._interleaved_computed_per_page_values_and_summaries |
| 64 | 65 |
| 65 def _ComputePerPageValues(self, all_page_specific_values): | 66 def _ComputePerPageValues(self, all_page_specific_values): |
| 66 all_successful_page_values = [ | 67 all_successful_page_values = [ |
| 67 v for v in all_page_specific_values if not (isinstance( | 68 v for v in all_page_specific_values if not (isinstance( |
| 68 v, failure.FailureValue) or isinstance(v, skip.SkipValue))] | 69 v, failure.FailureValue) or isinstance(v, skip.SkipValue))] |
| 69 | 70 |
| 71 # All successful values must be summarizable. | |
| 72 for v in all_successful_page_values: | |
| 73 assert isinstance(v, summarizable.SummarizableValue), "Not summarizable: % r" % v | |
|
qyearsley
2015/01/27 00:50:46
Looks like it's just over 80 chars. Also, I think
| |
| 74 | |
| 70 # We will later need to determine how many values were originally created | 75 # We will later need to determine how many values were originally created |
| 71 # for each value name, to apply a workaround meant to clean up the printf | 76 # for each value name, to apply a workaround meant to clean up the printf |
| 72 # output. | 77 # output. |
| 73 num_successful_pages_for_value_name = defaultdict(int) | 78 num_successful_pages_for_value_name = defaultdict(int) |
| 74 for v in all_successful_page_values: | 79 for v in all_successful_page_values: |
| 75 num_successful_pages_for_value_name[v.name] += 1 | 80 num_successful_pages_for_value_name[v.name] += 1 |
| 76 | 81 |
| 77 # By here, due to page repeat options, all_values_from_successful_pages | 82 # By here, due to page repeat options, all_values_from_successful_pages |
| 78 # contains values of the same name not only from mulitple pages, but also | 83 # contains values of the same name not only from mulitple pages, but also |
| 79 # from the same name. So even if, for instance, only one page ran, it may | 84 # from the same name. So even if, for instance, only one page ran, it may |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 should_print = True | 159 should_print = True |
| 155 else: | 160 else: |
| 156 should_print = False | 161 should_print = False |
| 157 | 162 |
| 158 if not should_print: | 163 if not should_print: |
| 159 return | 164 return |
| 160 | 165 |
| 161 # Actually save the result. | 166 # Actually save the result. |
| 162 self._computed_per_page_values.append(value) | 167 self._computed_per_page_values.append(value) |
| 163 self._interleaved_computed_per_page_values_and_summaries.append(value) | 168 self._interleaved_computed_per_page_values_and_summaries.append(value) |
| OLD | NEW |