| 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.core import wpr_modes | 5 from telemetry.core import wpr_modes |
| 6 from telemetry import decorators | 6 from telemetry import decorators |
| 7 from telemetry.page import page as page_module | 7 from telemetry.page import page as page_module |
| 8 from telemetry.results import page_test_results | 8 from telemetry.results import page_test_results |
| 9 from telemetry.timeline import model as model_module | 9 from telemetry.timeline import model as model_module |
| 10 from telemetry.timeline import slice as slice_data | 10 from telemetry.timeline import slice as slice_data |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 # Add too many increasing-durtation tasks and confirm we only get the | 154 # Add too many increasing-durtation tasks and confirm we only get the |
| 155 # slowest _NUMBER_OF_RESULTS_TO_DISPLAY tasks reported back. | 155 # slowest _NUMBER_OF_RESULTS_TO_DISPLAY tasks reported back. |
| 156 duration = 0 | 156 duration = 0 |
| 157 extra = 5 | 157 extra = 5 |
| 158 for duration in xrange( | 158 for duration in xrange( |
| 159 task_execution_time.TaskExecutionTime._NUMBER_OF_RESULTS_TO_DISPLAY + | 159 task_execution_time.TaskExecutionTime._NUMBER_OF_RESULTS_TO_DISPLAY + |
| 160 extra): | 160 extra): |
| 161 data.AddSlice('task' + str(duration), 0, duration) | 161 data.AddSlice('task' + str(duration), 0, duration) |
| 162 | 162 |
| 163 # Run the code we are testing. | 163 # Run the code we are testing. |
| 164 self._measurement.ValidateAndMeasurePage(None, None, data.results) | 164 self._measurement._AddResults(data.results) |
| 165 | 165 |
| 166 # Check that the last (i.e. biggest) _NUMBER_OF_RESULTS_TO_DISPLAY get | 166 # Check that the last (i.e. biggest) _NUMBER_OF_RESULTS_TO_DISPLAY get |
| 167 # returned in the results. | 167 # returned in the results. |
| 168 for duration in xrange( | 168 for duration in xrange( |
| 169 extra, | 169 extra, |
| 170 extra + | 170 extra + |
| 171 task_execution_time.TaskExecutionTime._NUMBER_OF_RESULTS_TO_DISPLAY): | 171 task_execution_time.TaskExecutionTime._NUMBER_OF_RESULTS_TO_DISPLAY): |
| 172 self._findResultFromName( | 172 self._findResultFromName( |
| 173 'process 1:%s:task%s' % (self._first_thread_name, str(duration)), | 173 'process 1:%s:task%s' % (self._first_thread_name, str(duration)), |
| 174 data) | 174 data) |
| 175 | 175 |
| 176 def _findResultFromName(self, name, data): | 176 def _findResultFromName(self, name, data): |
| 177 for result in data.results.all_page_specific_values: | 177 for result in data.results.all_page_specific_values: |
| 178 if result.name == name: | 178 if result.name == name: |
| 179 return result | 179 return result |
| 180 self.fail('Expected result "%s" missing.' % (name)) | 180 self.fail('Expected result "%s" missing.' % (name)) |
| 181 | 181 |
| 182 def _GenerateResultsFromMockedData(self): | 182 def _GenerateResultsFromMockedData(self): |
| 183 data = self._GenerateDataForEmptyPageSet() | 183 data = self._GenerateDataForEmptyPageSet() |
| 184 | 184 |
| 185 data.AddSlice('fast', 0, 1) | 185 data.AddSlice('fast', 0, 1) |
| 186 data.AddSlice('medium', 0, 500) | 186 data.AddSlice('medium', 0, 500) |
| 187 data.AddSlice('slow', 0, 1000) | 187 data.AddSlice('slow', 0, 1000) |
| 188 | 188 |
| 189 # Run the code we are testing and return results. | 189 # Run the code we are testing and return results. |
| 190 self._measurement.ValidateAndMeasurePage(None, None, data.results) | 190 self._measurement._AddResults(data.results) |
| 191 return data | 191 return data |
| 192 | 192 |
| 193 def _GenerateResultsFromMockedIdleData(self): | 193 def _GenerateResultsFromMockedIdleData(self): |
| 194 data = self._GenerateDataForEmptyPageSet() | 194 data = self._GenerateDataForEmptyPageSet() |
| 195 | 195 |
| 196 # Make a slice that looks like an idle task parent. | 196 # Make a slice that looks like an idle task parent. |
| 197 slice_start_time = 0 | 197 slice_start_time = 0 |
| 198 slow_slice_duration = 1000 | 198 slow_slice_duration = 1000 |
| 199 fast_slice_duration = 250 | 199 fast_slice_duration = 250 |
| 200 parent_slice = data.AddSlice( | 200 parent_slice = data.AddSlice( |
| 201 task_execution_time.TaskExecutionTime.IDLE_SECTION_TRIGGER, | 201 task_execution_time.TaskExecutionTime.IDLE_SECTION_TRIGGER, |
| 202 slice_start_time, | 202 slice_start_time, |
| 203 slow_slice_duration) | 203 slow_slice_duration) |
| 204 # Add a sub-slice, this should be reported back as occuring in idle time. | 204 # Add a sub-slice, this should be reported back as occuring in idle time. |
| 205 sub_slice = slice_data.Slice( | 205 sub_slice = slice_data.Slice( |
| 206 None, | 206 None, |
| 207 'category', | 207 'category', |
| 208 'slow_sub_slice', | 208 'slow_sub_slice', |
| 209 slice_start_time, | 209 slice_start_time, |
| 210 slow_slice_duration, | 210 slow_slice_duration, |
| 211 slice_start_time, | 211 slice_start_time, |
| 212 slow_slice_duration, | 212 slow_slice_duration, |
| 213 []) | 213 []) |
| 214 parent_slice.sub_slices.append(sub_slice) | 214 parent_slice.sub_slices.append(sub_slice) |
| 215 | 215 |
| 216 # Add a non-idle task. | 216 # Add a non-idle task. |
| 217 data.AddSlice('not_idle', slice_start_time, fast_slice_duration) | 217 data.AddSlice('not_idle', slice_start_time, fast_slice_duration) |
| 218 | 218 |
| 219 # Run the code we are testing. | 219 # Run the code we are testing. |
| 220 self._measurement.ValidateAndMeasurePage(None, None, data.results) | 220 self._measurement._AddResults(data.results) |
| 221 | 221 |
| 222 return data | 222 return data |
| 223 | 223 |
| 224 def _GenerateDataForEmptyPageSet(self): | 224 def _GenerateDataForEmptyPageSet(self): |
| 225 self._measurement = task_execution_time.TaskExecutionTime() | 225 self._measurement = task_execution_time.TaskExecutionTime() |
| 226 self._page_set = self.CreateEmptyPageSet() | 226 self._page_set = self.CreateEmptyPageSet() |
| 227 page = TestTaskExecutionTimePage(self._page_set, self._page_set.base_dir) | 227 page = TestTaskExecutionTimePage(self._page_set, self._page_set.base_dir) |
| 228 self._page_set.AddUserStory(page) | 228 self._page_set.AddUserStory(page) |
| 229 | 229 |
| 230 # Get the name of a thread used by task_execution_time metric and set up | 230 # Get the name of a thread used by task_execution_time metric and set up |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 None, | 265 None, |
| 266 'category', | 266 'category', |
| 267 name, | 267 name, |
| 268 timestamp, | 268 timestamp, |
| 269 duration, | 269 duration, |
| 270 timestamp, | 270 timestamp, |
| 271 duration, | 271 duration, |
| 272 []) | 272 []) |
| 273 self._renderer_thread.all_slices.append(new_slice) | 273 self._renderer_thread.all_slices.append(new_slice) |
| 274 return new_slice | 274 return new_slice |
| OLD | NEW |