Chromium Code Reviews| 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..540aadc878bd302a49cc8ab5e63f5134ad47d3ef |
| --- /dev/null |
| +++ b/tools/perf/perf_tools/tab_switching_benchmark.py |
| @@ -0,0 +1,57 @@ |
| +# 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. |
| +from perf_tools import histogram_measurement |
| +from telemetry.page import page_benchmark |
| + |
| +import os |
| +import time |
| + |
| +TAB_SWITCHING_HISTOGRAMS = [ |
| + {'name': 'MPArch.RWH_TabSwitchPaintDuration', 'units': ''},] |
| + |
| +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.histograms = [histogram_measurement.HistogramMeasurement( |
| + h, histogram_measurement.BROWSER_HISTOGRAM) |
| + for h in TAB_SWITCHING_HISTOGRAMS] |
| + for h in self.histograms: |
| + h.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", |
| + # These pages seem to be broken |
|
shatch
2013/03/29 19:17:22
Should these be replaced with new pages?
|
| + #"kannada.chakradeo.net", "ml.wikipedia.org" |
| + ] |
| + |
| + browser = tab.browser |
| + |
| + _, filename = page.serving_dirs_and_file |
| + launch_url = tab.browser.http_server.UrlOf(filename) |
| + |
| + tabs = [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(launch_url) |
| + tabs[i].EvaluateJavaScript('open_url("%s")' % cur_target_side_url) |
| + |
| + for i in range(1): |
| + for t in tabs: |
| + t.Activate() |
| + while t.EvaluateJavaScript('document.webkitHidden') != False: |
| + pass |
| + time.sleep(0.1) |
| + |
| + for h in self.histograms: |
| + h.GetValue(page, tab, results) |