OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 # Avoid paying for a cross-renderer navigation on the first page on legacy | 74 # Avoid paying for a cross-renderer navigation on the first page on legacy |
75 # page cyclers which use the filesystem. | 75 # page cyclers which use the filesystem. |
76 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) | 76 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) |
77 | 77 |
78 def WillNavigateToPage(self, page, tab): | 78 def WillNavigateToPage(self, page, tab): |
79 page.script_to_evaluate_on_commit = self._page_cycler_js | 79 page.script_to_evaluate_on_commit = self._page_cycler_js |
80 if self.ShouldRunCold(page.url): | 80 if self.ShouldRunCold(page.url): |
81 tab.ClearCache(force=True) | 81 tab.ClearCache(force=True) |
82 if self._report_speed_index: | 82 if self._report_speed_index: |
83 self._speedindex_metric.Start(page, tab) | 83 self._speedindex_metric.Start(page, tab) |
| 84 self._cpu_metric.Start(page, tab) |
84 | 85 |
85 def DidNavigateToPage(self, page, tab): | 86 def DidNavigateToPage(self, page, tab): |
86 self._memory_metric.Start(page, tab) | 87 self._memory_metric.Start(page, tab) |
87 self._power_metric.Start(page, tab) | 88 self._power_metric.Start(page, tab) |
88 # TODO(qyearsley): Uncomment the following line and move it to | |
89 # WillNavigateToPage once the cpu metric has been changed. | |
90 # This is being temporarily commented out to let the page cycler | |
91 # results return to how they were before the cpu metric was added. | |
92 # self._cpu_metric.Start(page, tab) See crbug.com/301714. | |
93 if self._record_v8_object_stats: | 89 if self._record_v8_object_stats: |
94 self._v8_object_stats_metric.Start(page, tab) | 90 self._v8_object_stats_metric.Start(page, tab) |
95 | 91 |
96 def CustomizeBrowserOptions(self, options): | 92 def CustomizeBrowserOptions(self, options): |
97 memory.MemoryMetric.CustomizeBrowserOptions(options) | 93 memory.MemoryMetric.CustomizeBrowserOptions(options) |
98 power.PowerMetric.CustomizeBrowserOptions(options) | 94 power.PowerMetric.CustomizeBrowserOptions(options) |
99 iometric.IOMetric.CustomizeBrowserOptions(options) | 95 iometric.IOMetric.CustomizeBrowserOptions(options) |
100 options.AppendExtraBrowserArgs('--js-flags=--expose_gc') | 96 options.AppendExtraBrowserArgs('--js-flags=--expose_gc') |
101 | 97 |
102 if self._record_v8_object_stats: | 98 if self._record_v8_object_stats: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 int(float(tab.EvaluateJavaScript('__pc_load_time'))), | 131 int(float(tab.EvaluateJavaScript('__pc_load_time'))), |
136 chart_name=chart_name_prefix+'times') | 132 chart_name=chart_name_prefix+'times') |
137 | 133 |
138 self._has_loaded_page[page.url] += 1 | 134 self._has_loaded_page[page.url] += 1 |
139 | 135 |
140 self._power_metric.Stop(page, tab) | 136 self._power_metric.Stop(page, tab) |
141 self._memory_metric.Stop(page, tab) | 137 self._memory_metric.Stop(page, tab) |
142 self._memory_metric.AddResults(tab, results) | 138 self._memory_metric.AddResults(tab, results) |
143 self._power_metric.AddResults(tab, results) | 139 self._power_metric.AddResults(tab, results) |
144 | 140 |
145 # TODO(qyearsley): Uncomment the following line when CPU metric is | 141 self._cpu_metric.Stop(page, tab) |
146 # changed. See crbug.com/301714. | 142 self._cpu_metric.AddResults(tab, results) |
147 # self._cpu_metric.Stop(page, tab) | |
148 # self._cpu_metric.AddResults(tab, results) | |
149 if self._record_v8_object_stats: | 143 if self._record_v8_object_stats: |
150 self._v8_object_stats_metric.Stop(page, tab) | 144 self._v8_object_stats_metric.Stop(page, tab) |
151 self._v8_object_stats_metric.AddResults(tab, results) | 145 self._v8_object_stats_metric.AddResults(tab, results) |
152 | 146 |
153 if self._report_speed_index: | 147 if self._report_speed_index: |
154 def SpeedIndexIsFinished(): | 148 def SpeedIndexIsFinished(): |
155 return self._speedindex_metric.IsFinished(tab) | 149 return self._speedindex_metric.IsFinished(tab) |
156 util.WaitFor(SpeedIndexIsFinished, 60) | 150 util.WaitFor(SpeedIndexIsFinished, 60) |
157 self._speedindex_metric.Stop(page, tab) | 151 self._speedindex_metric.Stop(page, tab) |
158 self._speedindex_metric.AddResults( | 152 self._speedindex_metric.AddResults( |
(...skipping 11 matching lines...) Expand all Loading... |
170 # preserve any initial profile cache for as long as possible. | 164 # preserve any initial profile cache for as long as possible. |
171 # The second is that, if we did cold runs first, we'd have a transition | 165 # The second is that, if we did cold runs first, we'd have a transition |
172 # page set during which we wanted the run for each URL to both | 166 # page set during which we wanted the run for each URL to both |
173 # contribute to the cold data and warm the catch for the following | 167 # contribute to the cold data and warm the catch for the following |
174 # warm run, and clearing the cache before the load of the following | 168 # warm run, and clearing the cache before the load of the following |
175 # URL would eliminate the intended warmup for the previous URL. | 169 # URL would eliminate the intended warmup for the previous URL. |
176 return (self._has_loaded_page[url] >= self._cold_run_start_index) | 170 return (self._has_loaded_page[url] >= self._cold_run_start_index) |
177 | 171 |
178 def results_are_the_same_on_every_page(self): | 172 def results_are_the_same_on_every_page(self): |
179 return False | 173 return False |
OLD | NEW |