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 |
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 metrics import cpu | 21 from metrics import cpu |
22 from metrics import iometric | 22 from metrics import iometric |
23 from metrics import memory | 23 from metrics import memory |
24 from metrics import power | 24 from metrics import power |
25 from metrics import speedindex | 25 from metrics import speedindex |
26 from metrics import v8_object_stats | 26 from metrics import v8_object_stats |
27 from telemetry.core import util | 27 from telemetry.core import util |
28 from telemetry.page import page_measurement | 28 from telemetry.page import page_measurement |
29 from telemetry.value import scalar | |
30 | |
29 | 31 |
30 class PageCycler(page_measurement.PageMeasurement): | 32 class PageCycler(page_measurement.PageMeasurement): |
31 options = {'pageset_repeat': 10} | 33 options = {'pageset_repeat': 10} |
32 | 34 |
33 def __init__(self, *args, **kwargs): | 35 def __init__(self, *args, **kwargs): |
34 super(PageCycler, self).__init__(*args, **kwargs) | 36 super(PageCycler, self).__init__(*args, **kwargs) |
35 | 37 |
36 with open(os.path.join(os.path.dirname(__file__), | 38 with open(os.path.join(os.path.dirname(__file__), |
37 'page_cycler.js'), 'r') as f: | 39 'page_cycler.js'), 'r') as f: |
38 self._page_cycler_js = f.read() | 40 self._page_cycler_js = f.read() |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 v8_object_stats.V8ObjectStatsMetric.CustomizeBrowserOptions(options) | 123 v8_object_stats.V8ObjectStatsMetric.CustomizeBrowserOptions(options) |
122 if self._report_speed_index: | 124 if self._report_speed_index: |
123 self._speedindex_metric.CustomizeBrowserOptions(options) | 125 self._speedindex_metric.CustomizeBrowserOptions(options) |
124 | 126 |
125 def MeasurePage(self, page, tab, results): | 127 def MeasurePage(self, page, tab, results): |
126 tab.WaitForJavaScriptExpression('__pc_load_time', 60) | 128 tab.WaitForJavaScriptExpression('__pc_load_time', 60) |
127 | 129 |
128 chart_name_prefix = ('cold_' if self.IsRunCold(page.url) else | 130 chart_name_prefix = ('cold_' if self.IsRunCold(page.url) else |
129 'warm_') | 131 'warm_') |
130 | 132 |
131 results.Add('page_load_time', 'ms', | 133 results.AddValue(scalar.ScalarValue( |
132 int(float(tab.EvaluateJavaScript('__pc_load_time'))), | 134 results.current_page, '%stimes.page_load_time' % chart_name_prefix, |
133 chart_name=chart_name_prefix+'times') | 135 'ms', int(float(tab.EvaluateJavaScript('__pc_load_time'))))) |
tonyg
2014/07/11 02:12:16
Not sure, but can we get rid of the int(float()) t
nednguyen
2014/07/11 03:10:39
Done.
| |
134 | 136 |
135 self._has_loaded_page[page.url] += 1 | 137 self._has_loaded_page[page.url] += 1 |
136 | 138 |
137 self._power_metric.Stop(page, tab) | 139 self._power_metric.Stop(page, tab) |
138 self._memory_metric.Stop(page, tab) | 140 self._memory_metric.Stop(page, tab) |
139 self._memory_metric.AddResults(tab, results) | 141 self._memory_metric.AddResults(tab, results) |
140 self._power_metric.AddResults(tab, results) | 142 self._power_metric.AddResults(tab, results) |
141 | 143 |
142 self._cpu_metric.Stop(page, tab) | 144 self._cpu_metric.Stop(page, tab) |
143 self._cpu_metric.AddResults(tab, results) | 145 self._cpu_metric.AddResults(tab, results) |
(...skipping 21 matching lines...) Expand all Loading... | |
165 # preserve any initial profile cache for as long as possible. | 167 # preserve any initial profile cache for as long as possible. |
166 # The second is that, if we did cold runs first, we'd have a transition | 168 # The second is that, if we did cold runs first, we'd have a transition |
167 # page set during which we wanted the run for each URL to both | 169 # page set during which we wanted the run for each URL to both |
168 # contribute to the cold data and warm the catch for the following | 170 # contribute to the cold data and warm the catch for the following |
169 # warm run, and clearing the cache before the load of the following | 171 # warm run, and clearing the cache before the load of the following |
170 # URL would eliminate the intended warmup for the previous URL. | 172 # URL would eliminate the intended warmup for the previous URL. |
171 return (self._has_loaded_page[url] >= self._cold_run_start_index) | 173 return (self._has_loaded_page[url] >= self._cold_run_start_index) |
172 | 174 |
173 def results_are_the_same_on_every_page(self): | 175 def results_are_the_same_on_every_page(self): |
174 return False | 176 return False |
OLD | NEW |