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 10 matching lines...) Expand all Loading... |
21 from perf_tools import histogram_metric | 21 from perf_tools import histogram_metric |
22 from telemetry.core import util | 22 from telemetry.core import util |
23 from telemetry.page import page_measurement | 23 from telemetry.page import page_measurement |
24 | 24 |
25 MEMORY_HISTOGRAMS = [ | 25 MEMORY_HISTOGRAMS = [ |
26 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, | 26 {'name': 'V8.MemoryExternalFragmentationTotal', 'units': 'percent'}, |
27 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, | 27 {'name': 'V8.MemoryHeapSampleTotalCommitted', 'units': 'kb'}, |
28 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}] | 28 {'name': 'V8.MemoryHeapSampleTotalUsed', 'units': 'kb'}] |
29 | 29 |
30 class PageCycler(page_measurement.PageMeasurement): | 30 class PageCycler(page_measurement.PageMeasurement): |
| 31 def __init__(self, *args, **kwargs): |
| 32 super(PageCycler, self).__init__(*args, **kwargs) |
| 33 |
| 34 with open(os.path.join(os.path.dirname(__file__), |
| 35 'page_cycler.js'), 'r') as f: |
| 36 self._page_cycler_js = f.read() |
| 37 |
| 38 self._start_commit_charge = None |
| 39 self._histograms = None |
| 40 |
31 def AddCommandLineOptions(self, parser): | 41 def AddCommandLineOptions(self, parser): |
32 # The page cyclers should default to 10 iterations. In order to change the | 42 # 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. | 43 # default of an option, we must remove and re-add it. |
34 pageset_repeat_option = parser.get_option('--pageset-repeat') | 44 pageset_repeat_option = parser.get_option('--pageset-repeat') |
35 pageset_repeat_option.default = 10 | 45 pageset_repeat_option.default = 10 |
36 parser.remove_option('--pageset-repeat') | 46 parser.remove_option('--pageset-repeat') |
37 parser.add_option(pageset_repeat_option) | 47 parser.add_option(pageset_repeat_option) |
38 | 48 |
39 def WillRunPageSet(self, tab, results): | 49 def SetUpBrowser(self, browser): |
40 # Avoid paying for a cross-renderer navigation on the first page on legacy | 50 self._start_commit_charge = browser.memory_stats['SystemCommitCharge'] |
41 # page cyclers which use the filesystem. | |
42 if tab.browser.http_server: | |
43 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) | |
44 | 51 |
45 with open(os.path.join(os.path.dirname(__file__), | 52 self._histograms = [histogram_metric.HistogramMetric( |
46 'page_cycler.js'), 'r') as f: | |
47 self.page_cycler_js = f.read() # pylint: disable=W0201 | |
48 | |
49 # pylint: disable=W0201 | |
50 self.start_commit_charge = tab.browser.memory_stats['SystemCommitCharge'] | |
51 | |
52 # pylint: disable=W0201 | |
53 self.histograms = [histogram_metric.HistogramMetric( | |
54 h, histogram_metric.RENDERER_HISTOGRAM) | 53 h, histogram_metric.RENDERER_HISTOGRAM) |
55 for h in MEMORY_HISTOGRAMS] | 54 for h in MEMORY_HISTOGRAMS] |
56 | 55 |
| 56 def DidStartHTTPServer(self, tab): |
| 57 # Avoid paying for a cross-renderer navigation on the first page on legacy |
| 58 # page cyclers which use the filesystem. |
| 59 tab.Navigate(tab.browser.http_server.UrlOf('nonexistent.html')) |
| 60 |
57 def WillNavigateToPage(self, page, tab): | 61 def WillNavigateToPage(self, page, tab): |
58 page.script_to_evaluate_on_commit = self.page_cycler_js | 62 page.script_to_evaluate_on_commit = self._page_cycler_js |
59 | 63 |
60 def DidNavigateToPage(self, page, tab): | 64 def DidNavigateToPage(self, page, tab): |
61 for h in self.histograms: | 65 for h in self._histograms: |
62 h.Start(page, tab) | 66 h.Start(page, tab) |
63 | 67 |
64 def CustomizeBrowserOptions(self, options): | 68 def CustomizeBrowserOptions(self, options): |
65 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') | 69 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') |
66 options.AppendExtraBrowserArg('--js-flags=--expose_gc') | 70 options.AppendExtraBrowserArg('--js-flags=--expose_gc') |
67 options.AppendExtraBrowserArg('--no-sandbox') | 71 options.AppendExtraBrowserArg('--no-sandbox') |
68 | 72 |
69 # Old commandline flags used for reference builds. | 73 # Old commandline flags used for reference builds. |
70 options.AppendExtraBrowserArg('--dom-automation') | 74 options.AppendExtraBrowserArg('--dom-automation') |
71 | 75 |
(...skipping 28 matching lines...) Expand all Loading... |
100 AddSummary('ProportionalSetSize', 'vm_proportional_set_size_final_') | 104 AddSummary('ProportionalSetSize', 'vm_proportional_set_size_final_') |
101 AddSummary('VMPeak', 'vm_peak_size_') | 105 AddSummary('VMPeak', 'vm_peak_size_') |
102 AddSummary('WorkingSetSizePeak', '%s_peak_size_' % metric) | 106 AddSummary('WorkingSetSizePeak', '%s_peak_size_' % metric) |
103 | 107 |
104 AddSummariesForProcessTypes(['Browser'], 'browser') | 108 AddSummariesForProcessTypes(['Browser'], 'browser') |
105 AddSummariesForProcessTypes(['Renderer'], 'renderer') | 109 AddSummariesForProcessTypes(['Renderer'], 'renderer') |
106 AddSummariesForProcessTypes(['Gpu'], 'gpu') | 110 AddSummariesForProcessTypes(['Gpu'], 'gpu') |
107 AddSummariesForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') | 111 AddSummariesForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') |
108 | 112 |
109 results.AddSummary('commit_charge', 'kb', | 113 results.AddSummary('commit_charge', 'kb', |
110 memory['SystemCommitCharge'] - self.start_commit_charge, | 114 memory['SystemCommitCharge'] - self._start_commit_charge, |
111 data_type='unimportant') | 115 data_type='unimportant') |
112 results.AddSummary('processes', 'count', memory['ProcessCount'], | 116 results.AddSummary('processes', 'count', memory['ProcessCount'], |
113 data_type='unimportant') | 117 data_type='unimportant') |
114 | 118 |
115 def MeasureIO(self, tab, results): | 119 def MeasureIO(self, tab, results): |
116 io_stats = tab.browser.io_stats | 120 io_stats = tab.browser.io_stats |
117 if not io_stats['Browser']: | 121 if not io_stats['Browser']: |
118 return | 122 return |
119 | 123 |
120 def AddSummariesForProcessType(process_type_io, process_type_trace): | 124 def AddSummariesForProcessType(process_type_io, process_type_trace): |
(...skipping 19 matching lines...) Expand all Loading... |
140 data_type='unimportant') | 144 data_type='unimportant') |
141 AddSummariesForProcessType('Browser', 'browser') | 145 AddSummariesForProcessType('Browser', 'browser') |
142 AddSummariesForProcessType('Renderer', 'renderer') | 146 AddSummariesForProcessType('Renderer', 'renderer') |
143 AddSummariesForProcessType('Gpu', 'gpu') | 147 AddSummariesForProcessType('Gpu', 'gpu') |
144 | 148 |
145 def MeasurePage(self, page, tab, results): | 149 def MeasurePage(self, page, tab, results): |
146 def _IsDone(): | 150 def _IsDone(): |
147 return bool(tab.EvaluateJavaScript('__pc_load_time')) | 151 return bool(tab.EvaluateJavaScript('__pc_load_time')) |
148 util.WaitFor(_IsDone, 60) | 152 util.WaitFor(_IsDone, 60) |
149 | 153 |
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 |