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