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 | 6 |
7 from metrics import Metric | 7 from metrics import Metric |
8 from telemetry.image_processing import image_util | 8 from telemetry.image_processing import image_util |
9 from telemetry.image_processing import rgba_color | 9 from telemetry.image_processing import rgba_color |
| 10 from telemetry.value import improvement_direction |
10 from telemetry.value import scalar | 11 from telemetry.value import scalar |
11 | 12 |
12 | 13 |
13 class SpeedIndexMetric(Metric): | 14 class SpeedIndexMetric(Metric): |
14 """The speed index metric is one way of measuring page load speed. | 15 """The speed index metric is one way of measuring page load speed. |
15 | 16 |
16 It is meant to approximate user perception of page load speed, and it | 17 It is meant to approximate user perception of page load speed, and it |
17 is based on the amount of time that it takes to paint to the visual | 18 is based on the amount of time that it takes to paint to the visual |
18 portion of the screen. It includes paint events that occur after the | 19 portion of the screen. It includes paint events that occur after the |
19 onload event, and it doesn't include time loading things off-screen. | 20 onload event, and it doesn't include time loading things off-screen. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 'smaller than the load time. On the other hand, If the ' | 64 'smaller than the load time. On the other hand, If the ' |
64 'contents are composed by many XHR requests with small ' | 65 'contents are composed by many XHR requests with small ' |
65 'main resource and javascript, speed index will be able to ' | 66 'main resource and javascript, speed index will be able to ' |
66 'get the features of performance more accurately than load ' | 67 'get the features of performance more accurately than load ' |
67 'time because the load time will measure the time when ' | 68 'time because the load time will measure the time when ' |
68 'static resources are loaded. If you want to get more ' | 69 'static resources are loaded. If you want to get more ' |
69 'detail, please refer to http://goo.gl/Rw3d5d. Currently ' | 70 'detail, please refer to http://goo.gl/Rw3d5d. Currently ' |
70 'there are two implementations: for Android and for ' | 71 'there are two implementations: for Android and for ' |
71 'Desktop. The Android version uses video capture; the ' | 72 'Desktop. The Android version uses video capture; the ' |
72 'Desktop one uses paint events and has extra overhead to ' | 73 'Desktop one uses paint events and has extra overhead to ' |
73 'catch paint events.')) | 74 'catch paint events.', |
| 75 improvement_direction=improvement_direction.DOWN)) |
74 | 76 |
75 def IsFinished(self, tab): | 77 def IsFinished(self, tab): |
76 """Decide whether the timeline recording should be stopped. | 78 """Decide whether the timeline recording should be stopped. |
77 | 79 |
78 When the timeline recording is stopped determines which paint events | 80 When the timeline recording is stopped determines which paint events |
79 are used in the speed index metric calculation. In general, the recording | 81 are used in the speed index metric calculation. In general, the recording |
80 should continue if there has just been some data received, because | 82 should continue if there has just been some data received, because |
81 this suggests that painting may continue. | 83 this suggests that painting may continue. |
82 | 84 |
83 A page may repeatedly request resources in an infinite loop; a timeout | 85 A page may repeatedly request resources in an infinite loop; a timeout |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 frame = paint_event.args['frameId'] | 319 frame = paint_event.args['frameId'] |
318 return (frame,) + GetBox(paint_event.args['data']['clip']) | 320 return (frame,) + GetBox(paint_event.args['data']['clip']) |
319 | 321 |
320 def _GroupEventByRectangle(self, paint_events): | 322 def _GroupEventByRectangle(self, paint_events): |
321 """Group all paint events according to the rectangle that they update.""" | 323 """Group all paint events according to the rectangle that they update.""" |
322 result = collections.defaultdict(list) | 324 result = collections.defaultdict(list) |
323 for event in paint_events: | 325 for event in paint_events: |
324 assert event.name == 'Paint' | 326 assert event.name == 'Paint' |
325 result[self._GetRectangle(event)].append(event) | 327 result[self._GetRectangle(event)].append(event) |
326 return result | 328 return result |
OLD | NEW |