| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 def CanRunForPage(self, page): | 24 def CanRunForPage(self, page): |
| 25 return not page.page_set.pages.index(page) | 25 return not page.page_set.pages.index(page) |
| 26 | 26 |
| 27 def DidNavigateToPage(self, page, tab): | 27 def DidNavigateToPage(self, page, tab): |
| 28 for i in xrange(1, len(page.page_set.pages)): | 28 for i in xrange(1, len(page.page_set.pages)): |
| 29 t = tab.browser.tabs.New() | 29 t = tab.browser.tabs.New() |
| 30 | 30 |
| 31 page_state = page_runner.PageState() | 31 page_state = page_runner.PageState() |
| 32 page_state.PreparePage(page.page_set.pages[i], t) | 32 page_state.PreparePage(page.page_set.pages[i], t) |
| 33 page_state.ImplicitPageNavigation(page.page_set.pages[i], t) |
| 33 | 34 |
| 34 def MeasurePage(self, _, tab, results): | 35 def MeasurePage(self, _, tab, results): |
| 35 """Although this is called MeasurePage, we're actually using this function | 36 """Although this is called MeasurePage, we're actually using this function |
| 36 to cycle through each tab that was opened via DidNavigateToPage and | 37 to cycle through each tab that was opened via DidNavigateToPage and |
| 37 thenrecord a single histogram for the tab switching metric. | 38 thenrecord a single histogram for the tab switching metric. |
| 38 """ | 39 """ |
| 39 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' | 40 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' |
| 40 histogram_type = 'getBrowserHistogram' | 41 histogram_type = 'getBrowserHistogram' |
| 41 first_histogram = histogram_util.GetHistogramFromDomAutomation( | 42 first_histogram = histogram_util.GetHistogramFromDomAutomation( |
| 42 histogram_type, histogram_name, tab) | 43 histogram_type, histogram_name, tab) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 prev_histogram = histogram_util.GetHistogramFromDomAutomation( | 56 prev_histogram = histogram_util.GetHistogramFromDomAutomation( |
| 56 histogram_type, histogram_name, tab) | 57 histogram_type, histogram_name, tab) |
| 57 | 58 |
| 58 last_histogram = histogram_util.GetHistogramFromDomAutomation( | 59 last_histogram = histogram_util.GetHistogramFromDomAutomation( |
| 59 histogram_type, histogram_name, tab) | 60 histogram_type, histogram_name, tab) |
| 60 diff_histogram = histogram_util.SubtractHistogram(last_histogram, | 61 diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
| 61 first_histogram) | 62 first_histogram) |
| 62 | 63 |
| 63 results.AddSummary(histogram_name, '', diff_histogram, | 64 results.AddSummary(histogram_name, '', diff_histogram, |
| 64 data_type='unimportant-histogram') | 65 data_type='unimportant-histogram') |
| OLD | NEW |