| 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 30 matching lines...) Expand all Loading... |
| 41 return | 41 return |
| 42 self._cpu_metric.Start(page, tab) | 42 self._cpu_metric.Start(page, tab) |
| 43 time.sleep(.5) | 43 time.sleep(.5) |
| 44 self._cpu_metric.Stop(page, tab) | 44 self._cpu_metric.Stop(page, tab) |
| 45 # Calculate the idle cpu load before any actions are done. | 45 # Calculate the idle cpu load before any actions are done. |
| 46 self._cpu_metric.AddResults(tab, results, | 46 self._cpu_metric.AddResults(tab, results, |
| 47 'idle_cpu_utilization') | 47 'idle_cpu_utilization') |
| 48 | 48 |
| 49 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' | 49 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' |
| 50 histogram_type = histogram_util.BROWSER_HISTOGRAM | 50 histogram_type = histogram_util.BROWSER_HISTOGRAM |
| 51 display_name = 'MPArch_RWH_TabSwitchPaintDuration' |
| 51 first_histogram = histogram_util.GetHistogram( | 52 first_histogram = histogram_util.GetHistogram( |
| 52 histogram_type, histogram_name, tab) | 53 histogram_type, histogram_name, tab) |
| 53 prev_histogram = first_histogram | 54 prev_histogram = first_histogram |
| 54 | 55 |
| 55 for i in xrange(len(tab.browser.tabs)): | 56 for i in xrange(len(tab.browser.tabs)): |
| 56 t = tab.browser.tabs[i] | 57 t = tab.browser.tabs[i] |
| 57 t.Activate() | 58 t.Activate() |
| 58 def _IsDone(): | 59 def _IsDone(): |
| 59 cur_histogram = histogram_util.GetHistogram( | 60 cur_histogram = histogram_util.GetHistogram( |
| 60 histogram_type, histogram_name, tab) | 61 histogram_type, histogram_name, tab) |
| 61 diff_histogram = histogram_util.SubtractHistogram( | 62 diff_histogram = histogram_util.SubtractHistogram( |
| 62 cur_histogram, prev_histogram) | 63 cur_histogram, prev_histogram) |
| 63 return diff_histogram | 64 return diff_histogram |
| 64 util.WaitFor(_IsDone, 30) | 65 util.WaitFor(_IsDone, 30) |
| 65 prev_histogram = histogram_util.GetHistogram( | 66 prev_histogram = histogram_util.GetHistogram( |
| 66 histogram_type, histogram_name, tab) | 67 histogram_type, histogram_name, tab) |
| 67 | 68 |
| 68 last_histogram = histogram_util.GetHistogram( | 69 last_histogram = histogram_util.GetHistogram( |
| 69 histogram_type, histogram_name, tab) | 70 histogram_type, histogram_name, tab) |
| 70 diff_histogram = histogram_util.SubtractHistogram(last_histogram, | 71 diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
| 71 first_histogram) | 72 first_histogram) |
| 72 | 73 |
| 73 results.AddSummary(histogram_name, '', diff_histogram, | 74 results.AddSummary(display_name, '', diff_histogram, |
| 74 data_type='unimportant-histogram') | 75 data_type='unimportant-histogram') |
| OLD | NEW |