Index: tools/perf/perf_tools/tab_switching_benchmark.py |
diff --git a/tools/perf/perf_tools/tab_switching_benchmark.py b/tools/perf/perf_tools/tab_switching_benchmark.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ad1f8486e6269a30a3a4f97fd2d21204187fce12 |
--- /dev/null |
+++ b/tools/perf/perf_tools/tab_switching_benchmark.py |
@@ -0,0 +1,48 @@ |
+# Copyright (c) 2013 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. |
+import os |
+ |
+from perf_tools import histogram_measurement |
+from telemetry.core import util |
+from telemetry.page import page_benchmark |
+ |
+TAB_SWITCHING_HISTOGRAMS = [ |
+ {'name': 'MPArch.RWH_TabSwitchPaintDuration', 'units': ''},] |
tonyg
2013/03/29 22:14:17
This is unused now
shatch
2013/03/29 22:59:12
Done.
|
+ |
+class TabSwitchingBenchmark(page_benchmark.PageBenchmark): |
+ def CustomizeBrowserOptions(self, options): |
+ options.AppendExtraBrowserArg('--dom-automation') |
+ options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') |
+ |
+ def WillNavigateToPage(self, page, tab): |
+ # pylint: disable=W0201 |
+ self.histogram = histogram_measurement.HistogramMeasurement( |
+ {'name': 'MPArch.RWH_TabSwitchPaintDuration', 'units': ''}, |
+ histogram_measurement.BROWSER_HISTOGRAM) |
+ |
+ self.histogram.Start(page, tab) |
+ |
+ def MeasurePage(self, page, tab, results): |
+ page_path = os.path.join('..', '..', '..', 'data', 'tab_switching') |
+ tab_urls = [ |
+ "espn.go.com", "bugzilla.mozilla.org", "news.cnet.com", "www.amazon.com", |
+ "allegro.pl", "www.bbc.co.uk", "126.com", "www.altavista.com", |
+ ] |
+ |
+ tabs = [tab] + [tab.browser.tabs.New() for i in xrange(len(tab_urls) - 1)] |
+ |
+ for i in xrange(len(tabs)): |
+ cur_filename = os.path.join(page_path, tab_urls[i], 'index.html') |
+ cur_target_side_url = tab.browser.http_server.UrlOf(cur_filename) |
+ |
+ tabs[i].Navigate(cur_target_side_url) |
+ |
+ for i in range(1): |
+ for t in tabs: |
+ t.Activate() |
+ def _IsDone(): |
+ return bool(not t.EvaluateJavaScript('document.webkitHidden')) |
tonyg
2013/03/29 22:14:17
Either the bool is unnecessary or the not is in th
shatch
2013/03/29 22:59:12
Done.
|
+ util.WaitFor(_IsDone, 500, poll_interval=5) |
+ |
+ self.histogram.GetValue(page, tab, results) |