| 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..1984ecc7f300798455bb93c129af401f747e1956
|
| --- /dev/null
|
| +++ b/tools/perf/perf_tools/tab_switching_benchmark.py
|
| @@ -0,0 +1,45 @@
|
| +# 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
|
| +
|
| +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 not t.EvaluateJavaScript('document.webkitHidden')
|
| + util.WaitFor(_IsDone, 500, poll_interval=5)
|
| +
|
| + self.histogram.GetValue(page, tab, results)
|
|
|