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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tools/perf/contrib/cros_benchmarks/tab_switching_measure.py
diff --git a/tools/perf/contrib/cros_benchmarks/tab_switching_measure.py b/tools/perf/contrib/cros_benchmarks/tab_switching_measure.py
new file mode 100644
index 0000000000000000000000000000000000000000..9e1fd9135193dd68174082070fc7e76565136e2a
--- /dev/null
+++ b/tools/perf/contrib/cros_benchmarks/tab_switching_measure.py
@@ -0,0 +1,49 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""The tab switching measurement.
+
+This measurement record the MPArch.RWH_TabSwitchPaintDuration histogram
+of each tab swithcing
+"""
+
+from telemetry.page import legacy_page_test
+from telemetry.value import histogram
+from telemetry.value import histogram_util
+
+
+class TabSwitchingMeasurement(legacy_page_test.LegacyPageTest):
+ def __init__(self):
+ super(TabSwitchingMeasurement, self).__init__()
+ self._first_histogram = None
+
+ def CustomizeBrowserOptions(self, options):
+ options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings'])
+
+ @classmethod
+ def _GetTabSwitchHistogram(cls, tab_to_switch):
+ histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
+ histogram_type = histogram_util.BROWSER_HISTOGRAM
+ return histogram_util.GetHistogram(
+ histogram_type, histogram_name, tab_to_switch)
+
+ def DidNavigateToPage(self, page, tab):
+ """record the starting histogram"""
+ # the browser shall focus on last tab now
+ last_tab = tab.browser.tabs[-1]
+ self._first_histogram = self._GetTabSwitchHistogram(last_tab)
+
+ def ValidateAndMeasurePage(self, page, tab, results):
+ """record the ending histogram for the tab switching metric."""
+ # the browser shall focus on last tab now
+ last_tab = tab.browser.tabs[-1]
+ last_histogram = self._GetTabSwitchHistogram(last_tab)
+ total_diff_histogram = histogram_util.SubtractHistogram(last_histogram,
+ self._first_histogram)
+
+ display_name = 'MPArch_RWH_TabSwitchPaintDuration'
+ results.AddSummaryValue(
+ histogram.HistogramValue(None, display_name, 'ms',
+ raw_value_json=total_diff_histogram,
+ important=False))

Powered by Google App Engine
This is Rietveld 408576698