Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 tab switching measurement. | 5 """The tab switching measurement. |
| 6 | 6 |
| 7 This measurement opens pages in different tabs. After all the tabs have opened, | 7 This measurement opens pages in different tabs. After all the tabs have opened, |
| 8 it cycles through each tab in sequence, and records a histogram of the time | 8 it cycles through each tab in sequence, and records a histogram of the time |
| 9 between when a tab was first requested to be shown, and when it was painted. | 9 between when a tab was first requested to be shown, and when it was painted. |
| 10 Power usage is also measured. | 10 Power usage is also measured. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 results.AddSummaryValue( | 114 results.AddSummaryValue( |
| 115 histogram.HistogramValue(None, display_name, 'ms', | 115 histogram.HistogramValue(None, display_name, 'ms', |
| 116 raw_value_json=total_diff_histogram, | 116 raw_value_json=total_diff_histogram, |
| 117 important=False)) | 117 important=False)) |
| 118 | 118 |
| 119 keychain_metric.KeychainMetric().AddResults(tab, results) | 119 keychain_metric.KeychainMetric().AddResults(tab, results) |
| 120 | 120 |
| 121 def DidRunPage(self, platform): | 121 def DidRunPage(self, platform): |
| 122 del platform # unused | 122 del platform # unused |
| 123 self._power_metric.Close() | 123 self._power_metric.Close() |
| 124 | |
| 125 class TabSwitching2(legacy_page_test.LegacyPageTest): | |
| 126 # Amount of time to measure, in seconds. | |
| 127 SAMPLE_TIME = 30 | |
| 128 | |
| 129 def __init__(self): | |
| 130 super(TabSwitching2, self).__init__() | |
| 131 self._power_metric = None | |
| 132 self._first_histogram = None | |
| 133 | |
| 134 def CustomizeBrowserOptions(self, options): | |
| 135 keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) | |
| 136 | |
| 137 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) | |
| 138 | |
| 139 # Enable background networking so we can test its impact on power usage. | |
| 140 options.disable_background_networking = False | |
| 141 power.PowerMetric.CustomizeBrowserOptions(options) | |
| 142 | |
| 143 def WillStartBrowser(self, platform): | |
| 144 self._power_metric = power.PowerMetric(platform, TabSwitching.SAMPLE_TIME) | |
| 145 | |
| 146 @classmethod | |
| 147 def _GetTabSwitchHistogram(cls, tab_to_switch): | |
| 148 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' | |
| 149 histogram_type = histogram_util.BROWSER_HISTOGRAM | |
| 150 return histogram_util.GetHistogram( | |
| 151 histogram_type, histogram_name, tab_to_switch) | |
| 152 | |
| 153 def DidNavigateToPage(self, page, tab): | |
| 154 """record the starting histogram""" | |
| 155 self._first_histogram = self._GetTabSwitchHistogram(tab) | |
| 156 | |
| 157 def ValidateAndMeasurePage(self, page, tab, results): | |
| 158 """record the ending histogram for the tab switching metric.""" | |
| 159 if tab.browser.platform.CanMonitorPower(): | |
| 160 self._power_metric.Start(page, tab) | |
| 161 time.sleep(TabSwitching.SAMPLE_TIME) | |
| 162 self._power_metric.Stop(page, tab) | |
| 163 self._power_metric.AddResults(tab, results,) | |
| 164 | |
| 165 last_histogram = self._GetTabSwitchHistogram(tab) | |
| 166 total_diff_histogram = histogram_util.SubtractHistogram(last_histogram, | |
| 167 self._first_histogram) | |
| 168 | |
| 169 display_name = 'MPArch_RWH_TabSwitchPaintDuration' | |
| 170 results.AddSummaryValue( | |
| 171 histogram.HistogramValue(None, display_name, 'ms', | |
| 172 raw_value_json=total_diff_histogram, | |
| 173 important=False)) | |
| 174 | |
| 175 keychain_metric.KeychainMetric().AddResults(tab, results) | |
| 176 | |
| 177 def DidRunPage(self, platform): | |
| 178 del platform # unused | |
| 179 self._power_metric.Close() | |
|
nednguyen
2017/03/21 14:46:12
Can you remove the legacy power_metric? The old po
vovoy
2017/03/23 09:37:49
Done.
| |
| 180 | |
| OLD | NEW |