| 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 """ | 10 """ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class TabSwitching(page_measurement.PageMeasurement): | 21 class TabSwitching(page_measurement.PageMeasurement): |
| 22 def __init__(self): | 22 def __init__(self): |
| 23 super(TabSwitching, self).__init__() | 23 super(TabSwitching, self).__init__() |
| 24 self._cpu_metric = None | 24 self._cpu_metric = None |
| 25 | 25 |
| 26 def CustomizeBrowserOptions(self, options): | 26 def CustomizeBrowserOptions(self, options): |
| 27 options.AppendExtraBrowserArgs([ | 27 options.AppendExtraBrowserArgs([ |
| 28 '--enable-stats-collection-bindings' | 28 '--enable-stats-collection-bindings' |
| 29 ]) | 29 ]) |
| 30 | 30 |
| 31 def TabForPage(self, page, tab): | 31 def TabForPage(self, page, browser): |
| 32 return tab.browser.tabs.New() | 32 return browser.tabs.New() |
| 33 | 33 |
| 34 def DidStartBrowser(self, browser): | 34 def DidStartBrowser(self, browser): |
| 35 self._cpu_metric = cpu.CpuMetric(browser) | 35 self._cpu_metric = cpu.CpuMetric(browser) |
| 36 | 36 |
| 37 def MeasurePage(self, page, tab, results): | 37 def MeasurePage(self, page, tab, results): |
| 38 """On the last tab, cycle through each tab that was opened and then record | 38 """On the last tab, cycle through each tab that was opened and then record |
| 39 a single histogram for the tab switching metric.""" | 39 a single histogram for the tab switching metric.""" |
| 40 if len(tab.browser.tabs) != len(page.page_set.pages): | 40 if len(tab.browser.tabs) != len(page.page_set.pages): |
| 41 return | 41 return |
| 42 self._cpu_metric.Start(page, tab) | 42 self._cpu_metric.Start(page, tab) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 65 prev_histogram = histogram_util.GetHistogram( | 65 prev_histogram = histogram_util.GetHistogram( |
| 66 histogram_type, histogram_name, tab) | 66 histogram_type, histogram_name, tab) |
| 67 | 67 |
| 68 last_histogram = histogram_util.GetHistogram( | 68 last_histogram = histogram_util.GetHistogram( |
| 69 histogram_type, histogram_name, tab) | 69 histogram_type, histogram_name, tab) |
| 70 diff_histogram = histogram_util.SubtractHistogram(last_histogram, | 70 diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
| 71 first_histogram) | 71 first_histogram) |
| 72 | 72 |
| 73 results.AddSummary(histogram_name, '', diff_histogram, | 73 results.AddSummary(histogram_name, '', diff_histogram, |
| 74 data_type='unimportant-histogram') | 74 data_type='unimportant-histogram') |
| OLD | NEW |