Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(831)

Side by Side Diff: tools/perf/contrib/cros_benchmarks/tab_switching_measure.py

Issue 2890333002: Tab Switching Benchmark for ChromeOS (Closed)
Patch Set: Tab Switching Benchmark for ChromeOS Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
16 class TabSwitchingMeasurement(legacy_page_test.LegacyPageTest):
17 def __init__(self):
18 super(TabSwitchingMeasurement, self).__init__()
19 self._first_histogram = None
20
21 def CustomizeBrowserOptions(self, options):
22 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings'])
23
24 @classmethod
25 def _GetTabSwitchHistogram(cls, tab_to_switch):
26 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
27 histogram_type = histogram_util.BROWSER_HISTOGRAM
28 return histogram_util.GetHistogram(
29 histogram_type, histogram_name, tab_to_switch)
30
31 def DidNavigateToPage(self, page, tab):
32 """record the starting histogram"""
33 # the browser shall focus on last tab now
34 last_tab = tab.browser.tabs[-1]
35 self._first_histogram = self._GetTabSwitchHistogram(last_tab)
36
37 def ValidateAndMeasurePage(self, page, tab, results):
38 """record the ending histogram for the tab switching metric."""
39 # the browser shall focus on last tab now
40 last_tab = tab.browser.tabs[-1]
41 last_histogram = self._GetTabSwitchHistogram(last_tab)
42 total_diff_histogram = histogram_util.SubtractHistogram(last_histogram,
43 self._first_histogram)
44
45 display_name = 'MPArch_RWH_TabSwitchPaintDuration'
46 results.AddSummaryValue(
47 histogram.HistogramValue(None, display_name, 'ms',
48 raw_value_json=total_diff_histogram,
49 important=False))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698