OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """The tab switching measurement. |
| 6 |
| 7 This measurement record the MPArch.RWH_TabSwitchPaintDuration histogram |
| 8 of each tab swithcing. |
| 9 """ |
| 10 |
| 11 from telemetry.page import legacy_page_test |
| 12 from telemetry.value import histogram |
| 13 from telemetry.value import histogram_util |
| 14 |
| 15 from contrib.cros_benchmarks import cros_utils |
| 16 |
| 17 |
| 18 class CrosTabSwitchingMeasurement(legacy_page_test.LegacyPageTest): |
| 19 """Measures tab switching performance.""" |
| 20 |
| 21 def __init__(self): |
| 22 super(CrosTabSwitchingMeasurement, self).__init__() |
| 23 self._first_histogram = None |
| 24 |
| 25 def CustomizeBrowserOptions(self, options): |
| 26 """Adding necessary browser flag to collect histogram.""" |
| 27 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) |
| 28 |
| 29 def DidNavigateToPage(self, page, tab): |
| 30 """Record the starting histogram.""" |
| 31 self._first_histogram = cros_utils.GetTabSwitchHistogramRetry(tab.browser) |
| 32 |
| 33 def ValidateAndMeasurePage(self, page, tab, results): |
| 34 """Record the ending histogram for the tab switching metric.""" |
| 35 last_histogram = cros_utils.GetTabSwitchHistogramRetry(tab.browser) |
| 36 total_diff_histogram = histogram_util.SubtractHistogram( |
| 37 last_histogram, self._first_histogram) |
| 38 |
| 39 display_name = 'MPArch_RWH_TabSwitchPaintDuration' |
| 40 results.AddSummaryValue( |
| 41 histogram.HistogramValue( |
| 42 None, display_name, 'ms', |
| 43 raw_value_json=total_diff_histogram, |
| 44 important=False)) |
OLD | NEW |