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. |
11 """ | 11 """ |
12 | 12 |
13 from telemetry.page import legacy_page_test | 13 from telemetry.page import legacy_page_test |
14 from telemetry.value import histogram | 14 from telemetry.value import histogram |
15 from telemetry.value import histogram_util | 15 from telemetry.value import histogram_util |
16 | 16 |
17 from metrics import keychain_metric | 17 from metrics import keychain_metric |
18 | 18 |
19 | 19 |
20 class TabSwitching(legacy_page_test.LegacyPageTest): | 20 class TabSwitching(legacy_page_test.LegacyPageTest): |
21 def __init__(self): | 21 def __init__(self): |
22 super(TabSwitching, self).__init__() | 22 super(TabSwitching, self).__init__() |
23 self._first_histogram = None | 23 self._first_histogram = None |
24 | 24 |
25 def CustomizeBrowserOptions(self, options): | 25 def CustomizeBrowserOptions(self, options): |
26 keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) | 26 keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) |
27 | 27 |
28 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) | 28 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) |
29 | 29 |
| 30 @property |
| 31 def is_multi_tab_test(self): |
| 32 return True |
| 33 |
30 @classmethod | 34 @classmethod |
31 def _GetTabSwitchHistogram(cls, tab_to_switch): | 35 def _GetTabSwitchHistogram(cls, tab_to_switch): |
32 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' | 36 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' |
33 histogram_type = histogram_util.BROWSER_HISTOGRAM | 37 histogram_type = histogram_util.BROWSER_HISTOGRAM |
34 return histogram_util.GetHistogram( | 38 return histogram_util.GetHistogram( |
35 histogram_type, histogram_name, tab_to_switch) | 39 histogram_type, histogram_name, tab_to_switch) |
36 | 40 |
37 def DidNavigateToPage(self, page, tab): | 41 def DidNavigateToPage(self, page, tab): |
38 """record the starting histogram""" | 42 """record the starting histogram""" |
39 self._first_histogram = self._GetTabSwitchHistogram(tab) | 43 self._first_histogram = self._GetTabSwitchHistogram(tab) |
40 | 44 |
41 def ValidateAndMeasurePage(self, page, tab, results): | 45 def ValidateAndMeasurePage(self, page, tab, results): |
42 """record the ending histogram for the tab switching metric.""" | 46 """record the ending histogram for the tab switching metric.""" |
43 last_histogram = self._GetTabSwitchHistogram(tab) | 47 last_histogram = self._GetTabSwitchHistogram(tab) |
44 total_diff_histogram = histogram_util.SubtractHistogram(last_histogram, | 48 total_diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
45 self._first_histogram) | 49 self._first_histogram) |
46 | 50 |
47 display_name = 'MPArch_RWH_TabSwitchPaintDuration' | 51 display_name = 'MPArch_RWH_TabSwitchPaintDuration' |
48 results.AddSummaryValue( | 52 results.AddSummaryValue( |
49 histogram.HistogramValue(None, display_name, 'ms', | 53 histogram.HistogramValue(None, display_name, 'ms', |
50 raw_value_json=total_diff_histogram, | 54 raw_value_json=total_diff_histogram, |
51 important=False)) | 55 important=False)) |
52 | 56 |
53 keychain_metric.KeychainMetric().AddResults(tab, results) | 57 keychain_metric.KeychainMetric().AddResults(tab, results) |
OLD | NEW |