| 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 18 matching lines...) Expand all Loading... |
| 29 for i in xrange(1, len(page.page_set.pages)): | 29 for i in xrange(1, len(page.page_set.pages)): |
| 30 t = tab.browser.tabs.New() | 30 t = tab.browser.tabs.New() |
| 31 | 31 |
| 32 page_state = page_runner.PageState() | 32 page_state = page_runner.PageState() |
| 33 page_state.PreparePage(page.page_set.pages[i], t) | 33 page_state.PreparePage(page.page_set.pages[i], t) |
| 34 page_state.ImplicitPageNavigation(page.page_set.pages[i], t) | 34 page_state.ImplicitPageNavigation(page.page_set.pages[i], t) |
| 35 | 35 |
| 36 def MeasurePage(self, _, tab, results): | 36 def MeasurePage(self, _, tab, results): |
| 37 """Although this is called MeasurePage, we're actually using this function | 37 """Although this is called MeasurePage, we're actually using this function |
| 38 to cycle through each tab that was opened via DidNavigateToPage and | 38 to cycle through each tab that was opened via DidNavigateToPage and |
| 39 thenrecord a single histogram for the tab switching metric. | 39 then record a single histogram for the tab switching metric. |
| 40 """ | 40 """ |
| 41 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' | 41 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' |
| 42 histogram_type = histogram_util.BROWSER_HISTOGRAM | 42 histogram_type = histogram_util.BROWSER_HISTOGRAM |
| 43 first_histogram = histogram_util.GetHistogramFromDomAutomation( | 43 first_histogram = histogram_util.GetHistogramFromDomAutomation( |
| 44 histogram_type, histogram_name, tab) | 44 histogram_type, histogram_name, tab) |
| 45 prev_histogram = first_histogram | 45 prev_histogram = first_histogram |
| 46 | 46 |
| 47 for i in xrange(len(tab.browser.tabs)): | 47 for i in xrange(len(tab.browser.tabs)): |
| 48 t = tab.browser.tabs[i] | 48 t = tab.browser.tabs[i] |
| 49 t.Activate() | 49 t.Activate() |
| 50 def _IsDone(): | 50 def _IsDone(): |
| 51 cur_histogram = histogram_util.GetHistogramFromDomAutomation( | 51 cur_histogram = histogram_util.GetHistogramFromDomAutomation( |
| 52 histogram_type, histogram_name, tab) | 52 histogram_type, histogram_name, tab) |
| 53 diff_histogram = histogram_util.SubtractHistogram( | 53 diff_histogram = histogram_util.SubtractHistogram( |
| 54 cur_histogram, prev_histogram) | 54 cur_histogram, prev_histogram) |
| 55 return diff_histogram | 55 return diff_histogram |
| 56 util.WaitFor(_IsDone, 30) | 56 util.WaitFor(_IsDone, 30) |
| 57 prev_histogram = histogram_util.GetHistogramFromDomAutomation( | 57 prev_histogram = histogram_util.GetHistogramFromDomAutomation( |
| 58 histogram_type, histogram_name, tab) | 58 histogram_type, histogram_name, tab) |
| 59 | 59 |
| 60 last_histogram = histogram_util.GetHistogramFromDomAutomation( | 60 last_histogram = histogram_util.GetHistogramFromDomAutomation( |
| 61 histogram_type, histogram_name, tab) | 61 histogram_type, histogram_name, tab) |
| 62 diff_histogram = histogram_util.SubtractHistogram(last_histogram, | 62 diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
| 63 first_histogram) | 63 first_histogram) |
| 64 | 64 |
| 65 results.AddSummary(histogram_name, '', diff_histogram, | 65 results.AddSummary(histogram_name, '', diff_histogram, |
| 66 data_type='unimportant-histogram') | 66 data_type='unimportant-histogram') |
| OLD | NEW |