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 | |
8 from telemetry.value import merge_values | 7 from telemetry.value import merge_values |
9 | 8 |
10 class Summary(object): | 9 class Summary(object): |
11 """Computes summary values from the per-page-run values produced by a test. | 10 """Computes summary values from the per-page-run values produced by a test. |
12 | 11 |
13 Some telemetry benchmark repeat a number of times in order to get a reliable | 12 Some telemetry benchmark repeat a number of times in order to get a reliable |
14 measurement. The test does not have to handle merging of these runs: | 13 measurement. The test does not have to handle merging of these runs: |
15 summarizer does it for you. | 14 summarizer does it for you. |
16 | 15 |
17 For instance, if two pages run, 3 and 1 time respectively: | 16 For instance, if two pages run, 3 and 1 time respectively: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 def interleaved_computed_per_page_values_and_summaries(self): | 51 def interleaved_computed_per_page_values_and_summaries(self): |
53 """Returns the computed per page values and summary values interleaved. | 52 """Returns the computed per page values and summary values interleaved. |
54 | 53 |
55 All the results for a given name are printed together. First per page | 54 All the results for a given name are printed together. First per page |
56 values, then summary values. | 55 values, then summary values. |
57 | 56 |
58 """ | 57 """ |
59 return self._interleaved_computed_per_page_values_and_summaries | 58 return self._interleaved_computed_per_page_values_and_summaries |
60 | 59 |
61 def _ComputePerPageValues(self, all_page_specific_values): | 60 def _ComputePerPageValues(self, all_page_specific_values): |
62 all_successful_page_values = [ | 61 all_successful_page_values = all_page_specific_values |
63 v for v in all_page_specific_values if not isinstance( | |
64 v, failure.FailureValue)] | |
65 | 62 |
66 # We will later need to determine how many values were originally created | 63 # We will later need to determine how many values were originally created |
67 # for each value name, to apply a workaround meant to clean up the printf | 64 # for each value name, to apply a workaround meant to clean up the printf |
68 # output. | 65 # output. |
69 num_successful_pages_for_value_name = defaultdict(int) | 66 num_successful_pages_for_value_name = defaultdict(int) |
70 for v in all_successful_page_values: | 67 for v in all_successful_page_values: |
71 num_successful_pages_for_value_name[v.name] += 1 | 68 num_successful_pages_for_value_name[v.name] += 1 |
72 | 69 |
73 # By here, due to page repeat options, all_values_from_successful_pages | 70 # By here, due to page repeat options, all_values_from_successful_pages |
74 # contains values of the same name not only from mulitple pages, but also | 71 # contains values of the same name not only from mulitple pages, but also |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 should_print = True | 147 should_print = True |
151 else: | 148 else: |
152 should_print = False | 149 should_print = False |
153 | 150 |
154 if not should_print: | 151 if not should_print: |
155 return | 152 return |
156 | 153 |
157 # Actually save the result. | 154 # Actually save the result. |
158 self._computed_per_page_values.append(value) | 155 self._computed_per_page_values.append(value) |
159 self._interleaved_computed_per_page_values_and_summaries.append(value) | 156 self._interleaved_computed_per_page_values_and_summaries.append(value) |
OLD | NEW |