Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 """The page cycler measurement. | 5 """The page cycler measurement. |
| 6 | 6 |
| 7 This measurement registers a window load handler in which is forces a layout and | 7 This measurement registers a window load handler in which is forces a layout and |
| 8 then records the value of performance.now(). This call to now() measures the | 8 then records the value of performance.now(). This call to now() measures the |
| 9 time from navigationStart (immediately after the previous page's beforeunload | 9 time from navigationStart (immediately after the previous page's beforeunload |
| 10 event) until after the layout in the page's load event. In addition, two garbage | 10 event) until after the layout in the page's load event. In addition, two garbage |
| 11 collections are performed in between the page loads (in the beforeunload event). | 11 collections are performed in between the page loads (in the beforeunload event). |
| 12 This extra garbage collection time is not included in the measurement times. | 12 This extra garbage collection time is not included in the measurement times. |
| 13 | 13 page_ |
|
nednguyen
2016/06/02 01:56:06
typo? :P
kouhei (in TOK)
2016/06/02 01:59:57
typo. Ack. Will fix and land
| |
| 14 Finally, various memory and IO statistics are gathered at the very end of | 14 Finally, various memory and IO statistics are gathered at the very end of |
| 15 cycling all pages. | 15 cycling all pages. |
| 16 """ | 16 """ |
| 17 | 17 |
| 18 import collections | 18 import collections |
| 19 import os | 19 import os |
| 20 | 20 |
| 21 from telemetry.core import util | 21 from telemetry.core import util |
| 22 from telemetry.page import legacy_page_test | 22 from telemetry.page import legacy_page_test |
| 23 from telemetry.value import scalar | 23 from telemetry.value import scalar |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 | 104 |
| 105 keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) | 105 keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) |
| 106 | 106 |
| 107 def ValidateAndMeasurePage(self, page, tab, results): | 107 def ValidateAndMeasurePage(self, page, tab, results): |
| 108 tab.WaitForJavaScriptExpression('__pc_load_time', 60) | 108 tab.WaitForJavaScriptExpression('__pc_load_time', 60) |
| 109 | 109 |
| 110 chart_name_prefix = ('cold_' if self.IsRunCold(page.url) else | 110 chart_name_prefix = ('cold_' if self.IsRunCold(page.url) else |
| 111 'warm_') | 111 'warm_') |
| 112 | 112 |
| 113 results.AddValue(scalar.ScalarValue( | 113 results.AddValue(scalar.ScalarValue( |
| 114 results.current_page, '%stimes-page_load_time' % chart_name_prefix, | |
| 115 'ms', tab.EvaluateJavaScript('__pc_load_time'), | |
| 116 description='Average page load time. Measured from ' | |
| 117 'performance.timing.navigationStart until the completion ' | |
| 118 'time of a layout after the window.load event. Cold times ' | |
| 119 'are the times when the page is loaded cold, i.e. without ' | |
| 120 'loading it before, and warm times are times when the ' | |
| 121 'page is loaded after being loaded previously.')) | |
| 122 results.AddValue(scalar.ScalarValue( | |
| 123 results.current_page, '%stimes-time_to_onload' % chart_name_prefix, | |
| 124 'ms', tab.EvaluateJavaScript('performance.timing.loadEventStart' | |
| 125 '- performance.timing.navigationStart'), | |
| 126 description='Time to onload. This is temporary metric to check that ' | |
| 127 'PCv1 and PCv2 emit similar results')) | |
| 128 | |
| 129 # TODO(kouhei): Remove below. crbug.com/616342 | |
| 130 results.AddValue(scalar.ScalarValue( | |
| 114 results.current_page, '%stimes.page_load_time' % chart_name_prefix, | 131 results.current_page, '%stimes.page_load_time' % chart_name_prefix, |
| 115 'ms', tab.EvaluateJavaScript('__pc_load_time'), | 132 'ms', tab.EvaluateJavaScript('__pc_load_time'), |
| 116 description='Average page load time. Measured from ' | 133 description='Average page load time. Measured from ' |
| 117 'performance.timing.navigationStart until the completion ' | 134 'performance.timing.navigationStart until the completion ' |
| 118 'time of a layout after the window.load event. Cold times ' | 135 'time of a layout after the window.load event. Cold times ' |
| 119 'are the times when the page is loaded cold, i.e. without ' | 136 'are the times when the page is loaded cold, i.e. without ' |
| 120 'loading it before, and warm times are times when the ' | 137 'loading it before, and warm times are times when the ' |
| 121 'page is loaded after being loaded previously.')) | 138 'page is loaded after being loaded previously.')) |
| 122 results.AddValue(scalar.ScalarValue( | 139 results.AddValue(scalar.ScalarValue( |
| 123 results.current_page, '%stimes.time_to_onload' % chart_name_prefix, | 140 results.current_page, '%stimes.time_to_onload' % chart_name_prefix, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 153 # preserve any initial profile cache for as long as possible. | 170 # preserve any initial profile cache for as long as possible. |
| 154 # The second is that, if we did cold runs first, we'd have a transition | 171 # The second is that, if we did cold runs first, we'd have a transition |
| 155 # page set during which we wanted the run for each URL to both | 172 # page set during which we wanted the run for each URL to both |
| 156 # contribute to the cold data and warm the catch for the following | 173 # contribute to the cold data and warm the catch for the following |
| 157 # warm run, and clearing the cache before the load of the following | 174 # warm run, and clearing the cache before the load of the following |
| 158 # URL would eliminate the intended warmup for the previous URL. | 175 # URL would eliminate the intended warmup for the previous URL. |
| 159 return self._has_loaded_page[url] >= self._cold_run_start_index | 176 return self._has_loaded_page[url] >= self._cold_run_start_index |
| 160 | 177 |
| 161 def DidRunPage(self, platform): | 178 def DidRunPage(self, platform): |
| 162 self._power_metric.Close() | 179 self._power_metric.Close() |
| OLD | NEW |