| 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. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 def ValidateAndMeasurePage(self, page, tab, results): | 56 def ValidateAndMeasurePage(self, page, tab, results): |
| 57 """On the last tab, cycle through each tab that was opened and then record | 57 """On the last tab, cycle through each tab that was opened and then record |
| 58 a single histogram for the tab switching metric.""" | 58 a single histogram for the tab switching metric.""" |
| 59 if len(tab.browser.tabs) != len(page.page_set.pages): | 59 if len(tab.browser.tabs) != len(page.page_set.pages): |
| 60 return | 60 return |
| 61 | 61 |
| 62 # Measure power usage of tabs after quiescence. | 62 # Measure power usage of tabs after quiescence. |
| 63 util.WaitFor(tab.HasReachedQuiescence, 60) | 63 util.WaitFor(tab.HasReachedQuiescence, 60) |
| 64 | 64 |
| 65 self._power_metric.Start(page, tab) | 65 if tab.browser.platform.CanMonitorPower(): |
| 66 time.sleep(TabSwitching.SAMPLE_TIME) | 66 self._power_metric.Start(page, tab) |
| 67 self._power_metric.Stop(page, tab) | 67 time.sleep(TabSwitching.SAMPLE_TIME) |
| 68 self._power_metric.AddResults(tab, results,) | 68 self._power_metric.Stop(page, tab) |
| 69 self._power_metric.AddResults(tab, results,) |
| 69 | 70 |
| 70 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' | 71 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' |
| 71 histogram_type = histogram_util.BROWSER_HISTOGRAM | 72 histogram_type = histogram_util.BROWSER_HISTOGRAM |
| 72 display_name = 'MPArch_RWH_TabSwitchPaintDuration' | 73 display_name = 'MPArch_RWH_TabSwitchPaintDuration' |
| 73 first_histogram = histogram_util.GetHistogram( | 74 first_histogram = histogram_util.GetHistogram( |
| 74 histogram_type, histogram_name, tab) | 75 histogram_type, histogram_name, tab) |
| 75 prev_histogram = first_histogram | 76 prev_histogram = first_histogram |
| 76 | 77 |
| 77 for i in xrange(len(tab.browser.tabs)): | 78 for i in xrange(len(tab.browser.tabs)): |
| 78 t = tab.browser.tabs[i] | 79 t = tab.browser.tabs[i] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 89 | 90 |
| 90 last_histogram = histogram_util.GetHistogram( | 91 last_histogram = histogram_util.GetHistogram( |
| 91 histogram_type, histogram_name, tab) | 92 histogram_type, histogram_name, tab) |
| 92 diff_histogram = histogram_util.SubtractHistogram(last_histogram, | 93 diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
| 93 first_histogram) | 94 first_histogram) |
| 94 | 95 |
| 95 results.AddSummaryValue( | 96 results.AddSummaryValue( |
| 96 histogram.HistogramValue(None, display_name, '', | 97 histogram.HistogramValue(None, display_name, '', |
| 97 raw_value_json=diff_histogram, | 98 raw_value_json=diff_histogram, |
| 98 important=False)) | 99 important=False)) |
| OLD | NEW |