Index: tools/perf/measurements/tab_switching.py |
diff --git a/tools/perf/measurements/tab_switching.py b/tools/perf/measurements/tab_switching.py |
index dd64dfa0d2f583d17afc72b67146ef3b9351c045..b041266600820c95a18032c5b27330ecca193a8b 100644 |
--- a/tools/perf/measurements/tab_switching.py |
+++ b/tools/perf/measurements/tab_switching.py |
@@ -121,3 +121,60 @@ class TabSwitching(legacy_page_test.LegacyPageTest): |
def DidRunPage(self, platform): |
del platform # unused |
self._power_metric.Close() |
+ |
+class TabSwitching2(legacy_page_test.LegacyPageTest): |
+ # Amount of time to measure, in seconds. |
+ SAMPLE_TIME = 30 |
+ |
+ def __init__(self): |
+ super(TabSwitching2, self).__init__() |
+ self._power_metric = None |
+ self._first_histogram = None |
+ |
+ def CustomizeBrowserOptions(self, options): |
+ keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) |
+ |
+ options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) |
+ |
+ # Enable background networking so we can test its impact on power usage. |
+ options.disable_background_networking = False |
+ power.PowerMetric.CustomizeBrowserOptions(options) |
+ |
+ def WillStartBrowser(self, platform): |
+ self._power_metric = power.PowerMetric(platform, TabSwitching.SAMPLE_TIME) |
+ |
+ @classmethod |
+ def _GetTabSwitchHistogram(cls, tab_to_switch): |
+ histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' |
+ histogram_type = histogram_util.BROWSER_HISTOGRAM |
+ return histogram_util.GetHistogram( |
+ histogram_type, histogram_name, tab_to_switch) |
+ |
+ def DidNavigateToPage(self, page, tab): |
+ """record the starting histogram""" |
+ self._first_histogram = self._GetTabSwitchHistogram(tab) |
+ |
+ def ValidateAndMeasurePage(self, page, tab, results): |
+ """record the ending histogram for the tab switching metric.""" |
+ if tab.browser.platform.CanMonitorPower(): |
+ self._power_metric.Start(page, tab) |
+ time.sleep(TabSwitching.SAMPLE_TIME) |
+ self._power_metric.Stop(page, tab) |
+ self._power_metric.AddResults(tab, results,) |
+ |
+ last_histogram = self._GetTabSwitchHistogram(tab) |
+ total_diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
+ self._first_histogram) |
+ |
+ display_name = 'MPArch_RWH_TabSwitchPaintDuration' |
+ results.AddSummaryValue( |
+ histogram.HistogramValue(None, display_name, 'ms', |
+ raw_value_json=total_diff_histogram, |
+ important=False)) |
+ |
+ keychain_metric.KeychainMetric().AddResults(tab, results) |
+ |
+ def DidRunPage(self, platform): |
+ del platform # unused |
+ 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.
|
+ |