Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (c) 2013 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 from perf_tools import histogram_measurement | |
| 5 from telemetry.page import page_benchmark | |
| 6 | |
| 7 import os | |
| 8 import time | |
| 9 | |
| 10 TAB_SWITCHING_HISTOGRAMS = [ | |
| 11 {'name': 'MPArch.RWH_TabSwitchPaintDuration', 'units': ''},] | |
| 12 | |
| 13 class TabSwitchingBenchmark(page_benchmark.PageBenchmark): | |
| 14 def CustomizeBrowserOptions(self, options): | |
| 15 options.AppendExtraBrowserArg('--dom-automation') | |
| 16 options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') | |
| 17 | |
| 18 def WillNavigateToPage(self, page, tab): | |
| 19 # pylint: disable=W0201 | |
| 20 self.histograms = [histogram_measurement.HistogramMeasurement( | |
| 21 h, histogram_measurement.BROWSER_HISTOGRAM) | |
| 22 for h in TAB_SWITCHING_HISTOGRAMS] | |
| 23 for h in self.histograms: | |
| 24 h.Start(page, tab) | |
| 25 | |
| 26 def MeasurePage(self, page, tab, results): | |
| 27 page_path = os.path.join('..', '..', '..', 'data', 'tab_switching') | |
| 28 tab_urls = [ | |
| 29 "espn.go.com", "bugzilla.mozilla.org", "news.cnet.com", "www.amazon.com", | |
| 30 "allegro.pl", "www.bbc.co.uk", "126.com", "www.altavista.com", | |
| 31 # These pages seem to be broken | |
|
shatch
2013/03/29 19:17:22
Should these be replaced with new pages?
| |
| 32 #"kannada.chakradeo.net", "ml.wikipedia.org" | |
| 33 ] | |
| 34 | |
| 35 browser = tab.browser | |
| 36 | |
| 37 _, filename = page.serving_dirs_and_file | |
| 38 launch_url = tab.browser.http_server.UrlOf(filename) | |
| 39 | |
| 40 tabs = [tab] + [browser.tabs.New() for i in xrange(len(tab_urls) - 1)] | |
| 41 | |
| 42 for i in xrange(len(tabs)): | |
| 43 cur_filename = os.path.join(page_path, tab_urls[i], 'index.html') | |
| 44 cur_target_side_url = tab.browser.http_server.UrlOf(cur_filename) | |
| 45 | |
| 46 tabs[i].Navigate(launch_url) | |
| 47 tabs[i].EvaluateJavaScript('open_url("%s")' % cur_target_side_url) | |
| 48 | |
| 49 for i in range(1): | |
| 50 for t in tabs: | |
| 51 t.Activate() | |
| 52 while t.EvaluateJavaScript('document.webkitHidden') != False: | |
| 53 pass | |
| 54 time.sleep(0.1) | |
| 55 | |
| 56 for h in self.histograms: | |
| 57 h.GetValue(page, tab, results) | |
| OLD | NEW |