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 import os | 5 import os |
6 import unittest | 6 import unittest |
7 | 7 |
8 from telemetry import story | 8 from telemetry import story |
9 from telemetry.internal.results import page_test_results | 9 from telemetry.internal.results import page_test_results |
10 from telemetry import page as page_module | 10 from telemetry import page as page_module |
11 from telemetry.value import failure | 11 from telemetry.value import failure |
12 from telemetry.value import histogram | 12 from telemetry.value import histogram |
| 13 from telemetry.value import improvement_direction |
13 from telemetry.value import list_of_scalar_values | 14 from telemetry.value import list_of_scalar_values |
14 from telemetry.value import scalar | 15 from telemetry.value import scalar |
15 from telemetry.value import summary as summary_module | 16 from telemetry.value import summary as summary_module |
16 | 17 |
17 | 18 |
18 class TestBase(unittest.TestCase): | 19 class TestBase(unittest.TestCase): |
19 def setUp(self): | 20 def setUp(self): |
20 story_set = story.StorySet(base_dir=os.path.dirname(__file__)) | 21 story_set = story.StorySet(base_dir=os.path.dirname(__file__)) |
21 story_set.AddStory( | 22 story_set.AddStory( |
22 page_module.Page('http://www.bar.com/', story_set, story_set.base_dir)) | 23 page_module.Page('http://www.bar.com/', story_set, story_set.base_dir)) |
23 story_set.AddStory( | 24 story_set.AddStory( |
24 page_module.Page('http://www.baz.com/', story_set, story_set.base_dir)) | 25 page_module.Page('http://www.baz.com/', story_set, story_set.base_dir)) |
25 story_set.AddStory( | 26 story_set.AddStory( |
26 page_module.Page('http://www.foo.com/', story_set, story_set.base_dir)) | 27 page_module.Page('http://www.foo.com/', story_set, story_set.base_dir)) |
27 self.story_set = story_set | 28 self.story_set = story_set |
28 | 29 |
29 @property | 30 @property |
30 def pages(self): | 31 def pages(self): |
31 return self.story_set.stories | 32 return self.story_set.stories |
32 | 33 |
33 | 34 |
34 class SummaryTest(TestBase): | 35 class SummaryTest(TestBase): |
35 def testBasicSummary(self): | 36 def testBasicSummary(self): |
36 page0 = self.pages[0] | 37 page0 = self.pages[0] |
37 page1 = self.pages[1] | 38 page1 = self.pages[1] |
38 | 39 |
39 results = page_test_results.PageTestResults() | 40 results = page_test_results.PageTestResults() |
40 | 41 |
41 results.WillRunPage(page0) | 42 results.WillRunPage(page0) |
42 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3) | 43 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3, |
| 44 improvement_direction=improvement_direction.UP) |
43 results.AddValue(v0) | 45 results.AddValue(v0) |
44 results.DidRunPage(page0) | 46 results.DidRunPage(page0) |
45 | 47 |
46 results.WillRunPage(page1) | 48 results.WillRunPage(page1) |
47 v1 = scalar.ScalarValue(page1, 'a', 'seconds', 7) | 49 v1 = scalar.ScalarValue(page1, 'a', 'seconds', 7, |
| 50 improvement_direction=improvement_direction.UP) |
48 results.AddValue(v1) | 51 results.AddValue(v1) |
49 results.DidRunPage(page1) | 52 results.DidRunPage(page1) |
50 | 53 |
51 summary = summary_module.Summary(results.all_page_specific_values) | 54 summary = summary_module.Summary(results.all_page_specific_values) |
52 values = summary.interleaved_computed_per_page_values_and_summaries | 55 values = summary.interleaved_computed_per_page_values_and_summaries |
53 | 56 |
54 v0_list = list_of_scalar_values.ListOfScalarValues( | 57 v0_list = list_of_scalar_values.ListOfScalarValues( |
55 page0, 'a', 'seconds', [3]) | 58 page0, 'a', 'seconds', [3], |
| 59 improvement_direction=improvement_direction.UP) |
56 v1_list = list_of_scalar_values.ListOfScalarValues( | 60 v1_list = list_of_scalar_values.ListOfScalarValues( |
57 page1, 'a', 'seconds', [7]) | 61 page1, 'a', 'seconds', [7], |
| 62 improvement_direction=improvement_direction.UP) |
58 merged_value = list_of_scalar_values.ListOfScalarValues( | 63 merged_value = list_of_scalar_values.ListOfScalarValues( |
59 None, 'a', 'seconds', [3, 7]) | 64 None, 'a', 'seconds', [3, 7], |
| 65 improvement_direction=improvement_direction.UP) |
60 | 66 |
61 self.assertEquals(3, len(values)) | 67 self.assertEquals(3, len(values)) |
62 self.assertIn(v0_list, values) | 68 self.assertIn(v0_list, values) |
63 self.assertIn(v1_list, values) | 69 self.assertIn(v1_list, values) |
64 self.assertIn(merged_value, values) | 70 self.assertIn(merged_value, values) |
65 | 71 |
66 def testBasicSummaryWithOnlyOnePage(self): | 72 def testBasicSummaryWithOnlyOnePage(self): |
67 page0 = self.pages[0] | 73 page0 = self.pages[0] |
68 | 74 |
69 results = page_test_results.PageTestResults() | 75 results = page_test_results.PageTestResults() |
70 | 76 |
71 results.WillRunPage(page0) | 77 results.WillRunPage(page0) |
72 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3) | 78 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3, |
| 79 improvement_direction=improvement_direction.UP) |
73 results.AddValue(v0) | 80 results.AddValue(v0) |
74 results.DidRunPage(page0) | 81 results.DidRunPage(page0) |
75 | 82 |
76 summary = summary_module.Summary(results.all_page_specific_values) | 83 summary = summary_module.Summary(results.all_page_specific_values) |
77 values = summary.interleaved_computed_per_page_values_and_summaries | 84 values = summary.interleaved_computed_per_page_values_and_summaries |
78 | 85 |
79 v0_list = list_of_scalar_values.ListOfScalarValues( | 86 v0_list = list_of_scalar_values.ListOfScalarValues( |
80 page0, 'a', 'seconds', [3]) | 87 page0, 'a', 'seconds', [3], |
| 88 improvement_direction=improvement_direction.UP) |
81 merged_list = list_of_scalar_values.ListOfScalarValues( | 89 merged_list = list_of_scalar_values.ListOfScalarValues( |
82 None, 'a', 'seconds', [3]) | 90 None, 'a', 'seconds', [3], |
| 91 improvement_direction=improvement_direction.UP) |
83 | 92 |
84 self.assertEquals(2, len(values)) | 93 self.assertEquals(2, len(values)) |
85 self.assertIn(v0_list, values) | 94 self.assertIn(v0_list, values) |
86 self.assertIn(merged_list, values) | 95 self.assertIn(merged_list, values) |
87 | 96 |
88 def testBasicSummaryNonuniformResults(self): | 97 def testBasicSummaryNonuniformResults(self): |
89 page0 = self.pages[0] | 98 page0 = self.pages[0] |
90 page1 = self.pages[1] | 99 page1 = self.pages[1] |
91 page2 = self.pages[2] | 100 page2 = self.pages[2] |
92 | 101 |
93 results = page_test_results.PageTestResults() | 102 results = page_test_results.PageTestResults() |
94 results.WillRunPage(page0) | 103 results.WillRunPage(page0) |
95 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3) | 104 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3, |
| 105 improvement_direction=improvement_direction.UP) |
96 results.AddValue(v0) | 106 results.AddValue(v0) |
97 v1 = scalar.ScalarValue(page0, 'b', 'seconds', 10) | 107 v1 = scalar.ScalarValue(page0, 'b', 'seconds', 10, |
| 108 improvement_direction=improvement_direction.UP) |
98 results.AddValue(v1) | 109 results.AddValue(v1) |
99 results.DidRunPage(page0) | 110 results.DidRunPage(page0) |
100 | 111 |
101 results.WillRunPage(page1) | 112 results.WillRunPage(page1) |
102 v2 = scalar.ScalarValue(page1, 'a', 'seconds', 3) | 113 v2 = scalar.ScalarValue(page1, 'a', 'seconds', 3, |
| 114 improvement_direction=improvement_direction.UP) |
103 results.AddValue(v2) | 115 results.AddValue(v2) |
104 v3 = scalar.ScalarValue(page1, 'b', 'seconds', 10) | 116 v3 = scalar.ScalarValue(page1, 'b', 'seconds', 10, |
| 117 improvement_direction=improvement_direction.UP) |
105 results.AddValue(v3) | 118 results.AddValue(v3) |
106 results.DidRunPage(page1) | 119 results.DidRunPage(page1) |
107 | 120 |
108 results.WillRunPage(page2) | 121 results.WillRunPage(page2) |
109 v4 = scalar.ScalarValue(page2, 'a', 'seconds', 7) | 122 v4 = scalar.ScalarValue(page2, 'a', 'seconds', 7, |
| 123 improvement_direction=improvement_direction.UP) |
110 results.AddValue(v4) | 124 results.AddValue(v4) |
111 # Note, page[2] does not report a 'b' metric. | 125 # Note, page[2] does not report a 'b' metric. |
112 results.DidRunPage(page2) | 126 results.DidRunPage(page2) |
113 | 127 |
114 summary = summary_module.Summary(results.all_page_specific_values) | 128 summary = summary_module.Summary(results.all_page_specific_values) |
115 values = summary.interleaved_computed_per_page_values_and_summaries | 129 values = summary.interleaved_computed_per_page_values_and_summaries |
116 | 130 |
117 v0_list = list_of_scalar_values.ListOfScalarValues( | 131 v0_list = list_of_scalar_values.ListOfScalarValues( |
118 page0, 'a', 'seconds', [3]) | 132 page0, 'a', 'seconds', [3], |
| 133 improvement_direction=improvement_direction.UP) |
119 v1_list = list_of_scalar_values.ListOfScalarValues( | 134 v1_list = list_of_scalar_values.ListOfScalarValues( |
120 page0, 'b', 'seconds', [10]) | 135 page0, 'b', 'seconds', [10], |
| 136 improvement_direction=improvement_direction.UP) |
121 v2_list = list_of_scalar_values.ListOfScalarValues( | 137 v2_list = list_of_scalar_values.ListOfScalarValues( |
122 page1, 'a', 'seconds', [3]) | 138 page1, 'a', 'seconds', [3], |
| 139 improvement_direction=improvement_direction.UP) |
123 v3_list = list_of_scalar_values.ListOfScalarValues( | 140 v3_list = list_of_scalar_values.ListOfScalarValues( |
124 page1, 'b', 'seconds', [10]) | 141 page1, 'b', 'seconds', [10], |
| 142 improvement_direction=improvement_direction.UP) |
125 v4_list = list_of_scalar_values.ListOfScalarValues( | 143 v4_list = list_of_scalar_values.ListOfScalarValues( |
126 page2, 'a', 'seconds', [7]) | 144 page2, 'a', 'seconds', [7], |
| 145 improvement_direction=improvement_direction.UP) |
127 | 146 |
128 a_summary = list_of_scalar_values.ListOfScalarValues( | 147 a_summary = list_of_scalar_values.ListOfScalarValues( |
129 None, 'a', 'seconds', [3, 3, 7]) | 148 None, 'a', 'seconds', [3, 3, 7], |
| 149 improvement_direction=improvement_direction.UP) |
130 b_summary = list_of_scalar_values.ListOfScalarValues( | 150 b_summary = list_of_scalar_values.ListOfScalarValues( |
131 None, 'b', 'seconds', [10, 10]) | 151 None, 'b', 'seconds', [10, 10], |
| 152 improvement_direction=improvement_direction.UP) |
132 | 153 |
133 self.assertEquals(7, len(values)) | 154 self.assertEquals(7, len(values)) |
134 self.assertIn(v0_list, values) | 155 self.assertIn(v0_list, values) |
135 self.assertIn(v1_list, values) | 156 self.assertIn(v1_list, values) |
136 self.assertIn(v2_list, values) | 157 self.assertIn(v2_list, values) |
137 self.assertIn(v3_list, values) | 158 self.assertIn(v3_list, values) |
138 self.assertIn(v4_list, values) | 159 self.assertIn(v4_list, values) |
139 self.assertIn(a_summary, values) | 160 self.assertIn(a_summary, values) |
140 self.assertIn(b_summary, values) | 161 self.assertIn(b_summary, values) |
141 | 162 |
142 def testBasicSummaryPassAndFailPage(self): | 163 def testBasicSummaryPassAndFailPage(self): |
143 """If a page failed, only print summary for individual pages.""" | 164 """If a page failed, only print summary for individual pages.""" |
144 page0 = self.pages[0] | 165 page0 = self.pages[0] |
145 page1 = self.pages[1] | 166 page1 = self.pages[1] |
146 | 167 |
147 results = page_test_results.PageTestResults() | 168 results = page_test_results.PageTestResults() |
148 results.WillRunPage(page0) | 169 results.WillRunPage(page0) |
149 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3) | 170 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3, |
| 171 improvement_direction=improvement_direction.UP) |
150 results.AddValue(v0) | 172 results.AddValue(v0) |
151 v1 = failure.FailureValue.FromMessage(page0, 'message') | 173 v1 = failure.FailureValue.FromMessage(page0, 'message') |
152 results.AddValue(v1) | 174 results.AddValue(v1) |
153 results.DidRunPage(page0) | 175 results.DidRunPage(page0) |
154 | 176 |
155 results.WillRunPage(page1) | 177 results.WillRunPage(page1) |
156 v2 = scalar.ScalarValue(page1, 'a', 'seconds', 7) | 178 v2 = scalar.ScalarValue(page1, 'a', 'seconds', 7, |
| 179 improvement_direction=improvement_direction.UP) |
157 results.AddValue(v2) | 180 results.AddValue(v2) |
158 results.DidRunPage(page1) | 181 results.DidRunPage(page1) |
159 | 182 |
160 summary = summary_module.Summary(results.all_page_specific_values) | 183 summary = summary_module.Summary(results.all_page_specific_values) |
161 values = summary.interleaved_computed_per_page_values_and_summaries | 184 values = summary.interleaved_computed_per_page_values_and_summaries |
162 | 185 |
163 v0_list = list_of_scalar_values.ListOfScalarValues( | 186 v0_list = list_of_scalar_values.ListOfScalarValues( |
164 page0, 'a', 'seconds', [3]) | 187 page0, 'a', 'seconds', [3], |
| 188 improvement_direction=improvement_direction.UP) |
165 v2_list = list_of_scalar_values.ListOfScalarValues( | 189 v2_list = list_of_scalar_values.ListOfScalarValues( |
166 page1, 'a', 'seconds', [7]) | 190 page1, 'a', 'seconds', [7], |
| 191 improvement_direction=improvement_direction.UP) |
167 | 192 |
168 self.assertEquals(2, len(values)) | 193 self.assertEquals(2, len(values)) |
169 self.assertIn(v0_list, values) | 194 self.assertIn(v0_list, values) |
170 self.assertIn(v2_list, values) | 195 self.assertIn(v2_list, values) |
171 | 196 |
172 def testRepeatedPagesetOneIterationOnePageFails(self): | 197 def testRepeatedPagesetOneIterationOnePageFails(self): |
173 """Page fails on one iteration, no averaged results should print.""" | 198 """Page fails on one iteration, no averaged results should print.""" |
174 page0 = self.pages[0] | 199 page0 = self.pages[0] |
175 page1 = self.pages[1] | 200 page1 = self.pages[1] |
176 | 201 |
177 results = page_test_results.PageTestResults() | 202 results = page_test_results.PageTestResults() |
178 results.WillRunPage(page0) | 203 results.WillRunPage(page0) |
179 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3) | 204 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3, |
| 205 improvement_direction=improvement_direction.UP) |
180 results.AddValue(v0) | 206 results.AddValue(v0) |
181 results.DidRunPage(page0) | 207 results.DidRunPage(page0) |
182 | 208 |
183 results.WillRunPage(page1) | 209 results.WillRunPage(page1) |
184 v1 = scalar.ScalarValue(page1, 'a', 'seconds', 7) | 210 v1 = scalar.ScalarValue(page1, 'a', 'seconds', 7, |
| 211 improvement_direction=improvement_direction.UP) |
185 results.AddValue(v1) | 212 results.AddValue(v1) |
186 v2 = failure.FailureValue.FromMessage(page1, 'message') | 213 v2 = failure.FailureValue.FromMessage(page1, 'message') |
187 results.AddValue(v2) | 214 results.AddValue(v2) |
188 results.DidRunPage(page1) | 215 results.DidRunPage(page1) |
189 | 216 |
190 results.WillRunPage(page0) | 217 results.WillRunPage(page0) |
191 v3 = scalar.ScalarValue(page0, 'a', 'seconds', 4) | 218 v3 = scalar.ScalarValue(page0, 'a', 'seconds', 4, |
| 219 improvement_direction=improvement_direction.UP) |
192 results.AddValue(v3) | 220 results.AddValue(v3) |
193 results.DidRunPage(page0) | 221 results.DidRunPage(page0) |
194 | 222 |
195 results.WillRunPage(page1) | 223 results.WillRunPage(page1) |
196 v4 = scalar.ScalarValue(page1, 'a', 'seconds', 8) | 224 v4 = scalar.ScalarValue(page1, 'a', 'seconds', 8, |
| 225 improvement_direction=improvement_direction.UP) |
197 results.AddValue(v4) | 226 results.AddValue(v4) |
198 results.DidRunPage(page1) | 227 results.DidRunPage(page1) |
199 | 228 |
200 summary = summary_module.Summary(results.all_page_specific_values) | 229 summary = summary_module.Summary(results.all_page_specific_values) |
201 values = summary.interleaved_computed_per_page_values_and_summaries | 230 values = summary.interleaved_computed_per_page_values_and_summaries |
202 | 231 |
203 page0_aggregated = list_of_scalar_values.ListOfScalarValues( | 232 page0_aggregated = list_of_scalar_values.ListOfScalarValues( |
204 page0, 'a', 'seconds', [3, 4]) | 233 page0, 'a', 'seconds', [3, 4], |
| 234 improvement_direction=improvement_direction.UP) |
205 page1_aggregated = list_of_scalar_values.ListOfScalarValues( | 235 page1_aggregated = list_of_scalar_values.ListOfScalarValues( |
206 page1, 'a', 'seconds', [7, 8]) | 236 page1, 'a', 'seconds', [7, 8], |
| 237 improvement_direction=improvement_direction.UP) |
207 | 238 |
208 self.assertEquals(2, len(values)) | 239 self.assertEquals(2, len(values)) |
209 self.assertIn(page0_aggregated, values) | 240 self.assertIn(page0_aggregated, values) |
210 self.assertIn(page1_aggregated, values) | 241 self.assertIn(page1_aggregated, values) |
211 | 242 |
212 def testRepeatedPages(self): | 243 def testRepeatedPages(self): |
213 page0 = self.pages[0] | 244 page0 = self.pages[0] |
214 page1 = self.pages[1] | 245 page1 = self.pages[1] |
215 | 246 |
216 results = page_test_results.PageTestResults() | 247 results = page_test_results.PageTestResults() |
217 results.WillRunPage(page0) | 248 results.WillRunPage(page0) |
218 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3) | 249 v0 = scalar.ScalarValue(page0, 'a', 'seconds', 3, |
| 250 improvement_direction=improvement_direction.UP) |
219 results.AddValue(v0) | 251 results.AddValue(v0) |
220 results.DidRunPage(page0) | 252 results.DidRunPage(page0) |
221 | 253 |
222 results.WillRunPage(page0) | 254 results.WillRunPage(page0) |
223 v2 = scalar.ScalarValue(page0, 'a', 'seconds', 4) | 255 v2 = scalar.ScalarValue(page0, 'a', 'seconds', 4, |
| 256 improvement_direction=improvement_direction.UP) |
224 results.AddValue(v2) | 257 results.AddValue(v2) |
225 results.DidRunPage(page0) | 258 results.DidRunPage(page0) |
226 | 259 |
227 results.WillRunPage(page1) | 260 results.WillRunPage(page1) |
228 v1 = scalar.ScalarValue(page1, 'a', 'seconds', 7) | 261 v1 = scalar.ScalarValue(page1, 'a', 'seconds', 7, |
| 262 improvement_direction=improvement_direction.UP) |
229 results.AddValue(v1) | 263 results.AddValue(v1) |
230 results.DidRunPage(page1) | 264 results.DidRunPage(page1) |
231 | 265 |
232 results.WillRunPage(page1) | 266 results.WillRunPage(page1) |
233 v3 = scalar.ScalarValue(page1, 'a', 'seconds', 8) | 267 v3 = scalar.ScalarValue(page1, 'a', 'seconds', 8, |
| 268 improvement_direction=improvement_direction.UP) |
234 results.AddValue(v3) | 269 results.AddValue(v3) |
235 results.DidRunPage(page1) | 270 results.DidRunPage(page1) |
236 | 271 |
237 summary = summary_module.Summary(results.all_page_specific_values) | 272 summary = summary_module.Summary(results.all_page_specific_values) |
238 values = summary.interleaved_computed_per_page_values_and_summaries | 273 values = summary.interleaved_computed_per_page_values_and_summaries |
239 | 274 |
240 page0_aggregated = list_of_scalar_values.ListOfScalarValues( | 275 page0_aggregated = list_of_scalar_values.ListOfScalarValues( |
241 page0, 'a', 'seconds', [3, 4]) | 276 page0, 'a', 'seconds', [3, 4], |
| 277 improvement_direction=improvement_direction.UP) |
242 page1_aggregated = list_of_scalar_values.ListOfScalarValues( | 278 page1_aggregated = list_of_scalar_values.ListOfScalarValues( |
243 page1, 'a', 'seconds', [7, 8]) | 279 page1, 'a', 'seconds', [7, 8], |
| 280 improvement_direction=improvement_direction.UP) |
244 a_summary = list_of_scalar_values.ListOfScalarValues( | 281 a_summary = list_of_scalar_values.ListOfScalarValues( |
245 None, 'a', 'seconds', [3, 4, 7, 8]) | 282 None, 'a', 'seconds', [3, 4, 7, 8], |
| 283 improvement_direction=improvement_direction.UP) |
246 | 284 |
247 self.assertEquals(3, len(values)) | 285 self.assertEquals(3, len(values)) |
248 self.assertIn(page0_aggregated, values) | 286 self.assertIn(page0_aggregated, values) |
249 self.assertIn(page1_aggregated, values) | 287 self.assertIn(page1_aggregated, values) |
250 self.assertIn(a_summary, values) | 288 self.assertIn(a_summary, values) |
251 | 289 |
252 def testPageRunsTwice(self): | 290 def testPageRunsTwice(self): |
253 page0 = self.pages[0] | 291 page0 = self.pages[0] |
254 | 292 |
255 results = page_test_results.PageTestResults() | 293 results = page_test_results.PageTestResults() |
256 | 294 |
257 results.WillRunPage(page0) | 295 results.WillRunPage(page0) |
258 v0 = scalar.ScalarValue(page0, 'b', 'seconds', 2) | 296 v0 = scalar.ScalarValue(page0, 'b', 'seconds', 2, |
| 297 improvement_direction=improvement_direction.UP) |
259 results.AddValue(v0) | 298 results.AddValue(v0) |
260 results.DidRunPage(page0) | 299 results.DidRunPage(page0) |
261 | 300 |
262 results.WillRunPage(page0) | 301 results.WillRunPage(page0) |
263 v1 = scalar.ScalarValue(page0, 'b', 'seconds', 3) | 302 v1 = scalar.ScalarValue(page0, 'b', 'seconds', 3, |
| 303 improvement_direction=improvement_direction.UP) |
264 results.AddValue(v1) | 304 results.AddValue(v1) |
265 results.DidRunPage(page0) | 305 results.DidRunPage(page0) |
266 | 306 |
267 summary = summary_module.Summary(results.all_page_specific_values) | 307 summary = summary_module.Summary(results.all_page_specific_values) |
268 values = summary.interleaved_computed_per_page_values_and_summaries | 308 values = summary.interleaved_computed_per_page_values_and_summaries |
269 | 309 |
270 page0_aggregated = list_of_scalar_values.ListOfScalarValues( | 310 page0_aggregated = list_of_scalar_values.ListOfScalarValues( |
271 page0, 'b', 'seconds', [2, 3]) | 311 page0, 'b', 'seconds', [2, 3], |
| 312 improvement_direction=improvement_direction.UP) |
272 b_summary = list_of_scalar_values.ListOfScalarValues( | 313 b_summary = list_of_scalar_values.ListOfScalarValues( |
273 None, 'b', 'seconds', [2, 3]) | 314 None, 'b', 'seconds', [2, 3], |
| 315 improvement_direction=improvement_direction.UP) |
274 | 316 |
275 self.assertEquals(2, len(values)) | 317 self.assertEquals(2, len(values)) |
276 self.assertIn(page0_aggregated, values) | 318 self.assertIn(page0_aggregated, values) |
277 self.assertIn(b_summary, values) | 319 self.assertIn(b_summary, values) |
278 | 320 |
279 def testListValue(self): | 321 def testListValue(self): |
280 page0 = self.pages[0] | 322 page0 = self.pages[0] |
281 page1 = self.pages[1] | 323 page1 = self.pages[1] |
282 | 324 |
283 results = page_test_results.PageTestResults() | 325 results = page_test_results.PageTestResults() |
284 | 326 |
285 results.WillRunPage(page0) | 327 results.WillRunPage(page0) |
286 v0 = list_of_scalar_values.ListOfScalarValues(page0, 'b', 'seconds', [2, 2]) | 328 v0 = list_of_scalar_values.ListOfScalarValues( |
| 329 page0, 'b', 'seconds', [2, 2], |
| 330 improvement_direction=improvement_direction.UP) |
287 results.AddValue(v0) | 331 results.AddValue(v0) |
288 results.DidRunPage(page0) | 332 results.DidRunPage(page0) |
289 | 333 |
290 results.WillRunPage(page1) | 334 results.WillRunPage(page1) |
291 v1 = list_of_scalar_values.ListOfScalarValues(page1, 'b', 'seconds', [3, 3]) | 335 v1 = list_of_scalar_values.ListOfScalarValues( |
| 336 page1, 'b', 'seconds', [3, 3], |
| 337 improvement_direction=improvement_direction.UP) |
292 results.AddValue(v1) | 338 results.AddValue(v1) |
293 results.DidRunPage(page1) | 339 results.DidRunPage(page1) |
294 | 340 |
295 summary = summary_module.Summary(results.all_page_specific_values) | 341 summary = summary_module.Summary(results.all_page_specific_values) |
296 values = summary.interleaved_computed_per_page_values_and_summaries | 342 values = summary.interleaved_computed_per_page_values_and_summaries |
297 | 343 |
298 b_summary = list_of_scalar_values.ListOfScalarValues( | 344 b_summary = list_of_scalar_values.ListOfScalarValues( |
299 None, 'b', 'seconds', [2, 2, 3, 3]) | 345 None, 'b', 'seconds', [2, 2, 3, 3], |
| 346 improvement_direction=improvement_direction.UP) |
300 | 347 |
301 self.assertEquals(3, len(values)) | 348 self.assertEquals(3, len(values)) |
302 self.assertIn(v0, values) | 349 self.assertIn(v0, values) |
303 self.assertIn(v1, values) | 350 self.assertIn(v1, values) |
304 self.assertIn(b_summary, values) | 351 self.assertIn(b_summary, values) |
305 | 352 |
306 def testHistogram(self): | 353 def testHistogram(self): |
307 page0 = self.pages[0] | 354 page0 = self.pages[0] |
308 page1 = self.pages[1] | 355 page1 = self.pages[1] |
309 | 356 |
310 results = page_test_results.PageTestResults() | 357 results = page_test_results.PageTestResults() |
311 results.WillRunPage(page0) | 358 results.WillRunPage(page0) |
312 v0 = histogram.HistogramValue( | 359 v0 = histogram.HistogramValue( |
313 page0, 'a', 'units', | 360 page0, 'a', 'units', |
314 raw_value_json='{"buckets": [{"low": 1, "high": 2, "count": 1}]}', | 361 raw_value_json='{"buckets": [{"low": 1, "high": 2, "count": 1}]}', |
315 important=False) | 362 important=False, improvement_direction=improvement_direction.UP) |
316 results.AddValue(v0) | 363 results.AddValue(v0) |
317 results.DidRunPage(page0) | 364 results.DidRunPage(page0) |
318 | 365 |
319 results.WillRunPage(page1) | 366 results.WillRunPage(page1) |
320 v1 = histogram.HistogramValue( | 367 v1 = histogram.HistogramValue( |
321 page1, 'a', 'units', | 368 page1, 'a', 'units', |
322 raw_value_json='{"buckets": [{"low": 2, "high": 3, "count": 1}]}', | 369 raw_value_json='{"buckets": [{"low": 2, "high": 3, "count": 1}]}', |
323 important=False) | 370 important=False, improvement_direction=improvement_direction.UP) |
324 results.AddValue(v1) | 371 results.AddValue(v1) |
325 results.DidRunPage(page1) | 372 results.DidRunPage(page1) |
326 | 373 |
327 summary = summary_module.Summary(results.all_page_specific_values) | 374 summary = summary_module.Summary(results.all_page_specific_values) |
328 values = summary.interleaved_computed_per_page_values_and_summaries | 375 values = summary.interleaved_computed_per_page_values_and_summaries |
329 | 376 |
330 self.assertEquals(2, len(values)) | 377 self.assertEquals(2, len(values)) |
331 self.assertIn(v0, values) | 378 self.assertIn(v0, values) |
332 self.assertIn(v1, values) | 379 self.assertIn(v1, values) |
OLD | NEW |