OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 collections | 5 import collections |
6 import logging | 6 import logging |
7 | 7 |
8 from metrics import Metric | |
9 from telemetry.image_processing import image_util | 8 from telemetry.image_processing import image_util |
10 from telemetry.image_processing import rgba_color | 9 from telemetry.image_processing import rgba_color |
11 from telemetry.value import scalar | 10 from telemetry.value import scalar |
12 | 11 |
| 12 from metrics import Metric |
| 13 |
13 | 14 |
14 class SpeedIndexMetric(Metric): | 15 class SpeedIndexMetric(Metric): |
15 """The speed index metric is one way of measuring page load speed. | 16 """The speed index metric is one way of measuring page load speed. |
16 | 17 |
17 It is meant to approximate user perception of page load speed, and it | 18 It is meant to approximate user perception of page load speed, and it |
18 is based on the amount of time that it takes to paint to the visual | 19 is based on the amount of time that it takes to paint to the visual |
19 portion of the screen. It includes paint events that occur after the | 20 portion of the screen. It includes paint events that occur after the |
20 onload event, and it doesn't include time loading things off-screen. | 21 onload event, and it doesn't include time loading things off-screen. |
21 | 22 |
22 This speed index metric is based on WebPageTest.org (WPT). | 23 This speed index metric is based on WebPageTest.org (WPT). |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 else: | 182 else: |
182 return 0.0 | 183 return 0.0 |
183 return 1 - histogram.Distance(final_histogram) / total_distance | 184 return 1 - histogram.Distance(final_histogram) / total_distance |
184 | 185 |
185 self._time_completeness_list = [(time, FrameProgress(hist)) | 186 self._time_completeness_list = [(time, FrameProgress(hist)) |
186 for time, hist in histograms] | 187 for time, hist in histograms] |
187 | 188 |
188 def GetTimeCompletenessList(self, tab): | 189 def GetTimeCompletenessList(self, tab): |
189 assert self._time_completeness_list, 'Must call Stop() first.' | 190 assert self._time_completeness_list, 'Must call Stop() first.' |
190 return self._time_completeness_list | 191 return self._time_completeness_list |
OLD | NEW |