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 | |
|
tonyg
2013/03/29 20:37:35
Style nit: put system imports before telemetry imp
shatch
2013/03/29 21:40:00
Done.
| |
| 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] | |
|
tonyg
2013/03/29 20:37:35
I know this is copy/paste from another benchmark,
shatch
2013/03/29 21:40:00
Done.
| |
| 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 | |
| 32 #"kannada.chakradeo.net", "ml.wikipedia.org" | |
|
tonyg
2013/03/29 20:37:35
I'd just omit these
shatch
2013/03/29 21:40:00
Done.
| |
| 33 ] | |
| 34 | |
| 35 _, filename = page.serving_dirs_and_file | |
| 36 launch_url = tab.browser.http_server.UrlOf(filename) | |
| 37 | |
| 38 tabs = [tab] + [tab.browser.tabs.New() for i in xrange(len(tab_urls) - 1)] | |
| 39 | |
| 40 for i in xrange(len(tabs)): | |
| 41 cur_filename = os.path.join(page_path, tab_urls[i], 'index.html') | |
| 42 cur_target_side_url = tab.browser.http_server.UrlOf(cur_filename) | |
| 43 | |
| 44 tabs[i].Navigate(launch_url) | |
|
tonyg
2013/03/29 20:37:35
What is the point of navigating to the launch URL
shatch
2013/03/29 21:40:00
Done.
| |
| 45 tabs[i].EvaluateJavaScript('open_url("%s")' % cur_target_side_url) | |
| 46 | |
| 47 for i in range(1): | |
| 48 for t in tabs: | |
| 49 t.Activate() | |
| 50 while t.EvaluateJavaScript('document.webkitHidden') != False: | |
|
tonyg
2013/03/29 20:37:35
Recommend using WaitFor() here.
shatch
2013/03/29 21:40:00
Done.
| |
| 51 pass | |
| 52 time.sleep(0.1) | |
|
tonyg
2013/03/29 20:37:35
Why sleep? Is this what the old test did?
shatch
2013/03/29 21:40:00
Done.
| |
| 53 | |
| 54 for h in self.histograms: | |
| 55 h.GetValue(page, tab, results) | |
| OLD | NEW |