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 def __init__(self): |
| 20 super(CrosTabSwitchingMeasurement, self).__init__() |
| 21 self._first_histogram = None |
| 22 |
| 23 def CustomizeBrowserOptions(self, options): |
| 24 """Adding necessary browser flag to collect histogram.""" |
| 25 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) |
| 26 |
| 27 def DidNavigateToPage(self, page, tab): |
| 28 """Record the starting histogram.""" |
| 29 self._first_histogram = cros_utils.GetTabSwitchHistogramRetry(tab.browser) |
| 30 |
| 31 def ValidateAndMeasurePage(self, page, tab, results): |
| 32 """Record the ending histogram for the tab switching metric.""" |
| 33 last_histogram = cros_utils.GetTabSwitchHistogramRetry(tab.browser) |
| 34 total_diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
| 35 self._first_histogram) |
| 36 |
| 37 display_name = 'MPArch_RWH_TabSwitchPaintDuration' |
| 38 results.AddSummaryValue( |
| 39 histogram.HistogramValue(None, display_name, 'ms', |
| 40 raw_value_json=total_diff_histogram, |
| 41 important=False)) |
OLD | NEW |