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

Side by Side Diff: tools/telemetry/telemetry/value/summary.py

Issue 390233002: Kill AddError/AddErrorMessage from PageTestResults. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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 from collections import defaultdict 5 from collections import defaultdict
6 6
7 from telemetry.value import merge_values 7 from telemetry.value import merge_values
8 8
9 class Summary(object): 9 class Summary(object):
10 """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.
(...skipping 14 matching lines...) Expand all
25 ListOfScalarValues(page1, 'foo', units='ms', [1,1,1])], 25 ListOfScalarValues(page1, 'foo', units='ms', [1,1,1])],
26 ListOfScalarValues(page2, 'foo', units='ms', [2])] 26 ListOfScalarValues(page2, 'foo', units='ms', [2])]
27 ] 27 ]
28 28
29 In addition, it will produce a summary value: 29 In addition, it will produce a summary value:
30 [ 30 [
31 ListOfScalarValues(page=None, 'foo', units='ms', [1,1,1,2])] 31 ListOfScalarValues(page=None, 'foo', units='ms', [1,1,1,2])]
32 ] 32 ]
33 33
34 """ 34 """
35 def __init__(self, all_page_specific_values, had_errors_or_failures): 35 def __init__(self, all_page_specific_values, had_failures):
36 self.had_errors_or_failures = had_errors_or_failures 36 self.had_failures = had_failures
37 self._computed_per_page_values = [] 37 self._computed_per_page_values = []
38 self._computed_summary_values = [] 38 self._computed_summary_values = []
39 self._interleaved_computed_per_page_values_and_summaries = [] 39 self._interleaved_computed_per_page_values_and_summaries = []
40 self._ComputePerPageValues(all_page_specific_values) 40 self._ComputePerPageValues(all_page_specific_values)
41 41
42 @property 42 @property
43 def computed_per_page_values(self): 43 def computed_per_page_values(self):
44 return self._computed_per_page_values 44 return self._computed_per_page_values
45 45
46 @property 46 @property
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 # that name. 93 # that name.
94 per_page_values_by_value_name = defaultdict(list) 94 per_page_values_by_value_name = defaultdict(list)
95 for value in merged_page_values: 95 for value in merged_page_values:
96 per_page_values_by_value_name[value.name].append(value) 96 per_page_values_by_value_name[value.name].append(value)
97 97
98 # We already have the x values in the values array. But, we also need 98 # We already have the x values in the values array. But, we also need
99 # the values merged across the pages. And, we will need them indexed by 99 # the values merged across the pages. And, we will need them indexed by
100 # value name so that we can find them when printing out value names in 100 # value name so that we can find them when printing out value names in
101 # alphabetical order. 101 # alphabetical order.
102 merged_pages_value_by_value_name = {} 102 merged_pages_value_by_value_name = {}
103 if not self.had_errors_or_failures: 103 if not self.had_failures:
104 for value in merge_values.MergeLikeValuesFromDifferentPages( 104 for value in merge_values.MergeLikeValuesFromDifferentPages(
105 all_successful_page_values): 105 all_successful_page_values):
106 assert value.name not in merged_pages_value_by_value_name 106 assert value.name not in merged_pages_value_by_value_name
107 merged_pages_value_by_value_name[value.name] = value 107 merged_pages_value_by_value_name[value.name] = value
108 108
109 # sorted_value names will govern the order we start printing values. 109 # sorted_value names will govern the order we start printing values.
110 value_names = set([v.name for v in merged_page_values]) 110 value_names = set([v.name for v in merged_page_values])
111 sorted_value_names = sorted(value_names) 111 sorted_value_names = sorted(value_names)
112 112
113 # Time to walk through the values by name, printing first the page-specific 113 # Time to walk through the values by name, printing first the page-specific
(...skipping 21 matching lines...) Expand all
135 self._interleaved_computed_per_page_values_and_summaries.append( 135 self._interleaved_computed_per_page_values_and_summaries.append(
136 merged_pages_value) 136 merged_pages_value)
137 137
138 def _ComputePerPageValue( 138 def _ComputePerPageValue(
139 self, value, num_successful_pages_for_this_value_name): 139 self, value, num_successful_pages_for_this_value_name):
140 # If there were any page errors, we typically will print nothing. 140 # If there were any page errors, we typically will print nothing.
141 # 141 #
142 # Note: this branch is structured less-densely to improve legibility. 142 # Note: this branch is structured less-densely to improve legibility.
143 if num_successful_pages_for_this_value_name > 1: 143 if num_successful_pages_for_this_value_name > 1:
144 should_print = True 144 should_print = True
145 elif (self.had_errors_or_failures and 145 elif (self.had_failures and
146 num_successful_pages_for_this_value_name == 1): 146 num_successful_pages_for_this_value_name == 1):
147 should_print = True 147 should_print = True
148 else: 148 else:
149 should_print = False 149 should_print = False
150 150
151 if not should_print: 151 if not should_print:
152 return 152 return
153 153
154 # Actually save the result. 154 # Actually save the result.
155 self._computed_per_page_values.append(value) 155 self._computed_per_page_values.append(value)
156 self._interleaved_computed_per_page_values_and_summaries.append(value) 156 self._interleaved_computed_per_page_values_and_summaries.append(value)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698