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 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 class PageCycler(page_measurement.PageMeasurement): | 30 class PageCycler(page_measurement.PageMeasurement): |
31 def AddCommandLineOptions(self, parser): | 31 def AddCommandLineOptions(self, parser): |
32 # The page cyclers should default to 10 iterations. In order to change the | 32 # The page cyclers should default to 10 iterations. In order to change the |
33 # default of an option, we must remove and re-add it. | 33 # default of an option, we must remove and re-add it. |
34 pageset_repeat_option = parser.get_option('--pageset-repeat') | 34 pageset_repeat_option = parser.get_option('--pageset-repeat') |
35 pageset_repeat_option.default = 10 | 35 pageset_repeat_option.default = 10 |
36 parser.remove_option('--pageset-repeat') | 36 parser.remove_option('--pageset-repeat') |
37 parser.add_option(pageset_repeat_option) | 37 parser.add_option(pageset_repeat_option) |
38 | 38 |
39 parser.add_option('--cold-page-loads', action='store_true', | |
nduca
2013/06/20 19:54:15
rather you not expose it as a commandline. just bl
tonyg
2013/06/21 22:36:18
Done (reluctantly, as I still think this is a usef
| |
40 help='Make page loads cold by clearing browser cache between loads.') | |
41 | |
42 | |
39 def WillRunPageSet(self, tab, results): | 43 def WillRunPageSet(self, tab, results): |
40 # Avoid paying for a cross-renderer navigation on the first page on legacy | 44 # Avoid paying for a cross-renderer navigation on the first page on legacy |
41 # page cyclers which use the filesystem. | 45 # page cyclers which use the filesystem. |
42 if tab.browser.http_server: | 46 if tab.browser.http_server: |
43 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) | 47 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) |
44 | 48 |
45 with open(os.path.join(os.path.dirname(__file__), | 49 with open(os.path.join(os.path.dirname(__file__), |
46 'page_cycler.js'), 'r') as f: | 50 'page_cycler.js'), 'r') as f: |
47 self.page_cycler_js = f.read() # pylint: disable=W0201 | 51 self.page_cycler_js = f.read() # pylint: disable=W0201 |
48 | 52 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 for h in self.histograms: | 154 for h in self.histograms: |
151 h.GetValue(page, tab, results) | 155 h.GetValue(page, tab, results) |
152 | 156 |
153 results.Add('page_load_time', 'ms', | 157 results.Add('page_load_time', 'ms', |
154 int(float(tab.EvaluateJavaScript('__pc_load_time'))), | 158 int(float(tab.EvaluateJavaScript('__pc_load_time'))), |
155 chart_name='times') | 159 chart_name='times') |
156 | 160 |
157 def DidRunPageSet(self, tab, results): | 161 def DidRunPageSet(self, tab, results): |
158 self.MeasureMemory(tab, results) | 162 self.MeasureMemory(tab, results) |
159 self.MeasureIO(tab, results) | 163 self.MeasureIO(tab, results) |
OLD | NEW |