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 import time | 13 import time |
14 | 14 |
15 from metrics import keychain_metric | 15 from metrics import keychain_metric |
16 from metrics import power | 16 from metrics import power |
17 from telemetry.core import util | 17 from telemetry.core import util |
18 from telemetry.page import page_test | 18 from telemetry.page import page_test |
19 from telemetry.value import histogram | 19 from telemetry.value import histogram |
20 from telemetry.value import histogram_util | 20 from telemetry.value import histogram_util |
21 | 21 |
22 # TODO: Revisit this test once multitab support is finalized. | 22 # TODO: Revisit this test once multitab support is finalized. |
23 | 23 |
24 class TabSwitching(page_test.PageTest): | 24 class TabSwitching(page_test.PageTest): |
25 | 25 |
26 # Amount of time to measure, in seconds. | 26 # Amount of time to measure, in seconds. |
27 SAMPLE_TIME = 30 | 27 SAMPLE_TIME = 30 |
28 | 28 |
29 def __init__(self): | 29 def __init__(self): |
30 super(TabSwitching, self).__init__() | 30 super(TabSwitching, self).__init__(action_name_to_run='RunPageInteractions') |
31 self._first_page_in_pageset = True | 31 self._first_page_in_pageset = True |
32 self._power_metric = None | 32 self._power_metric = None |
33 | 33 |
34 def CustomizeBrowserOptions(self, options): | 34 def CustomizeBrowserOptions(self, options): |
35 keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) | 35 keychain_metric.KeychainMetric.CustomizeBrowserOptions(options) |
36 | 36 |
37 options.AppendExtraBrowserArgs([ | 37 options.AppendExtraBrowserArgs([ |
38 '--enable-stats-collection-bindings' | 38 '--enable-stats-collection-bindings' |
39 ]) | 39 ]) |
40 # Enable background networking so we can test its impact on power usage. | 40 # Enable background networking so we can test its impact on power usage. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 histogram_type, histogram_name, tab) | 97 histogram_type, histogram_name, tab) |
98 diff_histogram = histogram_util.SubtractHistogram(last_histogram, | 98 diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
99 first_histogram) | 99 first_histogram) |
100 | 100 |
101 results.AddSummaryValue( | 101 results.AddSummaryValue( |
102 histogram.HistogramValue(None, display_name, 'ms', | 102 histogram.HistogramValue(None, display_name, 'ms', |
103 raw_value_json=diff_histogram, | 103 raw_value_json=diff_histogram, |
104 important=False)) | 104 important=False)) |
105 | 105 |
106 keychain_metric.KeychainMetric().AddResults(tab, results) | 106 keychain_metric.KeychainMetric().AddResults(tab, results) |
OLD | NEW |