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 import os |
| 5 |
| 6 from perf_tools import histogram_measurement |
| 7 from telemetry.core import util |
| 8 from telemetry.page import page_benchmark |
| 9 |
| 10 class TabSwitchingBenchmark(page_benchmark.PageBenchmark): |
| 11 def CustomizeBrowserOptions(self, options): |
| 12 options.AppendExtraBrowserArg('--dom-automation') |
| 13 options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') |
| 14 |
| 15 def WillNavigateToPage(self, page, tab): |
| 16 # pylint: disable=W0201 |
| 17 self.histogram = histogram_measurement.HistogramMeasurement( |
| 18 {'name': 'MPArch.RWH_TabSwitchPaintDuration', 'units': ''}, |
| 19 histogram_measurement.BROWSER_HISTOGRAM) |
| 20 |
| 21 self.histogram.Start(page, tab) |
| 22 |
| 23 def MeasurePage(self, page, tab, results): |
| 24 page_path = os.path.join('..', '..', '..', 'data', 'tab_switching') |
| 25 tab_urls = [ |
| 26 "espn.go.com", "bugzilla.mozilla.org", "news.cnet.com", "www.amazon.com", |
| 27 "allegro.pl", "www.bbc.co.uk", "126.com", "www.altavista.com", |
| 28 ] |
| 29 |
| 30 tabs = [tab] + [tab.browser.tabs.New() for i in xrange(len(tab_urls) - 1)] |
| 31 |
| 32 for i in xrange(len(tabs)): |
| 33 cur_filename = os.path.join(page_path, tab_urls[i], 'index.html') |
| 34 cur_target_side_url = tab.browser.http_server.UrlOf(cur_filename) |
| 35 |
| 36 tabs[i].Navigate(cur_target_side_url) |
| 37 |
| 38 for i in range(1): |
| 39 for t in tabs: |
| 40 t.Activate() |
| 41 def _IsDone(): |
| 42 return not t.EvaluateJavaScript('document.webkitHidden') |
| 43 util.WaitFor(_IsDone, 500, poll_interval=5) |
| 44 |
| 45 self.histogram.GetValue(page, tab, results) |
OLD | NEW |