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 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 with open(os.path.join(os.path.dirname(__file__), | 38 with open(os.path.join(os.path.dirname(__file__), |
39 'page_cycler.js'), 'r') as f: | 39 'page_cycler.js'), 'r') as f: |
40 self._page_cycler_js = f.read() | 40 self._page_cycler_js = f.read() |
41 | 41 |
42 self._speedindex_metric = speedindex.SpeedIndexMetric() | 42 self._speedindex_metric = speedindex.SpeedIndexMetric() |
43 self._memory_metric = None | 43 self._memory_metric = None |
44 self._power_metric = None | 44 self._power_metric = None |
45 self._cpu_metric = None | 45 self._cpu_metric = None |
46 self._v8_object_stats_metric = None | 46 self._v8_object_stats_metric = None |
47 self._has_loaded_page = collections.defaultdict(int) | 47 self._has_loaded_page = collections.defaultdict(int) |
48 self._initial_renderer_url = None # to avoid cross-renderer navigation | |
48 | 49 |
49 @classmethod | 50 @classmethod |
50 def AddCommandLineArgs(cls, parser): | 51 def AddCommandLineArgs(cls, parser): |
51 parser.add_option('--v8-object-stats', | 52 parser.add_option('--v8-object-stats', |
52 action='store_true', | 53 action='store_true', |
53 help='Enable detailed V8 object statistics.') | 54 help='Enable detailed V8 object statistics.') |
54 | 55 |
55 parser.add_option('--report-speed-index', | 56 parser.add_option('--report-speed-index', |
56 action='store_true', | 57 action='store_true', |
57 help='Enable the speed index metric.') | 58 help='Enable the speed index metric.') |
(...skipping 29 matching lines...) Expand all Loading... | |
87 """Initialize metrics once right before the browser has been launched.""" | 88 """Initialize metrics once right before the browser has been launched.""" |
88 self._power_metric = power.PowerMetric(browser) | 89 self._power_metric = power.PowerMetric(browser) |
89 | 90 |
90 def DidStartBrowser(self, browser): | 91 def DidStartBrowser(self, browser): |
91 """Initialize metrics once right after the browser has been launched.""" | 92 """Initialize metrics once right after the browser has been launched.""" |
92 self._memory_metric = memory.MemoryMetric(browser) | 93 self._memory_metric = memory.MemoryMetric(browser) |
93 self._cpu_metric = cpu.CpuMetric(browser) | 94 self._cpu_metric = cpu.CpuMetric(browser) |
94 if self._record_v8_object_stats: | 95 if self._record_v8_object_stats: |
95 self._v8_object_stats_metric = v8_object_stats.V8ObjectStatsMetric() | 96 self._v8_object_stats_metric = v8_object_stats.V8ObjectStatsMetric() |
96 | 97 |
97 def DidStartHTTPServer(self, tab): | 98 def WillNavigateToPage(self, page, tab): |
98 # Avoid paying for a cross-renderer navigation on the first page on legacy | 99 if page.is_file: |
tonyg
2014/09/11 22:13:15
Looks like this'll work. An alternate approach wou
| |
99 # page cyclers which use the filesystem. | 100 # For legacy page cyclers which use the filesystem, do an initial |
100 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) | 101 # navigate to avoid paying for a cross-renderer navigation. |
102 initial_url = tab.browser.http_server.UrlOf('nonexistent.html') | |
103 if self._initial_renderer_url != initial_url: | |
104 self._initial_renderer_url = initial_url | |
105 tab.Navigate(self._initial_renderer_url) | |
101 | 106 |
102 def WillNavigateToPage(self, page, tab): | |
103 page.script_to_evaluate_on_commit = self._page_cycler_js | 107 page.script_to_evaluate_on_commit = self._page_cycler_js |
104 if self.ShouldRunCold(page.url): | 108 if self.ShouldRunCold(page.url): |
105 tab.ClearCache(force=True) | 109 tab.ClearCache(force=True) |
106 if self._report_speed_index: | 110 if self._report_speed_index: |
107 self._speedindex_metric.Start(page, tab) | 111 self._speedindex_metric.Start(page, tab) |
108 self._cpu_metric.Start(page, tab) | 112 self._cpu_metric.Start(page, tab) |
109 self._power_metric.Start(page, tab) | 113 self._power_metric.Start(page, tab) |
110 | 114 |
111 def DidNavigateToPage(self, page, tab): | 115 def DidNavigateToPage(self, page, tab): |
112 self._memory_metric.Start(page, tab) | 116 self._memory_metric.Start(page, tab) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 | 174 |
171 def ShouldRunCold(self, url): | 175 def ShouldRunCold(self, url): |
172 # We do the warm runs first for two reasons. The first is so we can | 176 # We do the warm runs first for two reasons. The first is so we can |
173 # preserve any initial profile cache for as long as possible. | 177 # preserve any initial profile cache for as long as possible. |
174 # The second is that, if we did cold runs first, we'd have a transition | 178 # The second is that, if we did cold runs first, we'd have a transition |
175 # page set during which we wanted the run for each URL to both | 179 # page set during which we wanted the run for each URL to both |
176 # contribute to the cold data and warm the catch for the following | 180 # contribute to the cold data and warm the catch for the following |
177 # warm run, and clearing the cache before the load of the following | 181 # warm run, and clearing the cache before the load of the following |
178 # URL would eliminate the intended warmup for the previous URL. | 182 # URL would eliminate the intended warmup for the previous URL. |
179 return (self._has_loaded_page[url] >= self._cold_run_start_index) | 183 return (self._has_loaded_page[url] >= self._cold_run_start_index) |
OLD | NEW |