Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: tools/perf/contrib/cros_benchmarks/tab_switching_stories.py

Issue 2890333002: Tab Switching Benchmark for ChromeOS (Closed)
Patch Set: Tab Switching Benchmark for ChromeOS Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/perf/contrib/cros_benchmarks/tab_switching_measure.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/contrib/cros_benchmarks/tab_switching_stories.py
diff --git a/tools/perf/contrib/cros_benchmarks/tab_switching_stories.py b/tools/perf/contrib/cros_benchmarks/tab_switching_stories.py
new file mode 100644
index 0000000000000000000000000000000000000000..89e81fb59c9bc69401d588059e0aef77ee08a7d8
--- /dev/null
+++ b/tools/perf/contrib/cros_benchmarks/tab_switching_stories.py
@@ -0,0 +1,120 @@
+# Copyright 2017 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 py_utils
+import logging
+
+from telemetry.core import exceptions
+from telemetry.page import page as page_module
+from telemetry.page import shared_page_state
+from contrib.cros_benchmarks import cros_utils
+
+
+# NOTE: When tab count is high, some tabs may be discarded, and the tab
+# context would be invalidated. Avoid storing tab object for later use.
+class CrosMultiTabStory(page_module.Page):
+ """Base class for multi-tab stories."""
+
+ def __init__(self, story_set, cros_remote, tabset_repeat=1):
+ super(CrosMultiTabStory, self).__init__(
+ shared_page_state_class=shared_page_state.SharedPageState,
+ page_set=story_set, name=self.NAME, url=self.URL)
+ self._cros_remote = cros_remote
+ self._tabset_repeat = tabset_repeat
+
+ def RunNavigateSteps(self, action_runner):
+ """Opening tabs and waiting for them to load."""
+ if not self._cros_remote:
+ raise ValueError('Must specify --remote=DUT_IP to run this test.')
+
+ # As this story may run for a long time, adjusting screen off time to
+ # avoid screen off.
+ cros_utils.NoScreenOff(self._cros_remote)
+
+ tabs = action_runner.tab.browser.tabs
+
+ # No need to create the first tab as there is already one
+ # when the browser is ready.
+ url_list = self.URL_LIST * self._tabset_repeat
+ if url_list:
+ action_runner.Navigate(url_list[0])
+ for i, url in enumerate(url_list[1:]):
+ new_tab = tabs.New()
+ new_tab.action_runner.Navigate(url)
+ if i % 10 == 0:
+ print 'opening tab:', i
+
+ # Waiting for every tabs to be stable.
+ for i, url in enumerate(url_list):
+ try:
+ tabs[i].action_runner.WaitForNetworkQuiescence()
+ except py_utils.TimeoutException:
+ logging.info('WaitForNetworkQuiescence() timeout, url[%d]: %s',
+ i, url)
+ except exceptions.DevtoolsTargetCrashException:
+ logging.info('RunNavigateSteps: devtools context lost')
+
+ def RunPageInteractions(self, action_runner):
+ """Tab switching to each tabs."""
+ url_list = self.URL_LIST * self._tabset_repeat
+ browser = action_runner.tab.browser
+
+ total_tab_count = len(url_list)
+ live_tab_count = len(browser.tabs)
+ if live_tab_count != total_tab_count:
+ logging.warning('live tab: %d, tab discarded: %d',
+ live_tab_count, total_tab_count - live_tab_count)
+
+ with cros_utils.KeyboardEmulator(self._cros_remote) as keyboard:
+ for i in range(total_tab_count):
+ prev_histogram = cros_utils.GetTabSwitchHistogramRetry(browser)
+ keyboard.SwitchTab()
+ cros_utils.WaitTabSwitching(browser, prev_histogram)
+
+ if i % 10 == 0:
+ print 'switching tab:', i
+
+
+class CrosMultiTabTypical24Story(CrosMultiTabStory):
+ """Multi-tab stories to test 24 typical webpages."""
+ NAME = 'cros_tab_switching_typical24'
+ URL_LIST = [
+ # Why: Alexa games #48
+ 'http://www.nick.com/games',
+ # Why: Alexa sports #45
+ 'http://www.rei.com/',
+ # Why: Alexa sports #50
+ 'http://www.fifa.com/',
+ # Why: Alexa shopping #41
+ 'http://www.gamestop.com/ps3',
+ # Why: Alexa news #55
+ ('http://www.economist.com/news/science-and-technology/21573529-small-'
+ 'models-cosmic-phenomena-are-shedding-light-real-thing-how-build'),
+ # Why: Alexa news #67
+ 'http://www.theonion.com',
+ 'http://arstechnica.com/',
+ # Why: Alexa home #10
+ 'http://allrecipes.com/Recipe/Pull-Apart-Hot-Cross-Buns/Detail.aspx',
+ 'http://www.html5rocks.com/en/',
+ 'http://www.mlb.com/',
+ ('http://gawker.com/5939683/based-on-a-true-story-is-a-rotten-lie-i-'
+ 'hope-you-never-believe'),
+ 'http://www.imdb.com/title/tt0910970/',
+ 'http://www.flickr.com/search/?q=monkeys&f=hp',
+ 'http://money.cnn.com/',
+ 'http://www.nationalgeographic.com/',
+ 'http://premierleague.com',
+ 'http://www.osubeavers.com/',
+ 'http://walgreens.com',
+ 'http://colorado.edu',
+ ('http://www.ticketmaster.com/JAY-Z-and-Justin-Timberlake-tickets/artist/'
+ '1837448?brand=none&tm_link=tm_homeA_rc_name2'),
+ # pylint: disable=line-too-long
+ 'http://www.theverge.com/2013/3/5/4061684/inside-ted-the-smartest-bubble-in-the-world',
+ 'http://www.airbnb.com/',
+ 'http://www.ign.com/',
+ # Why: Alexa health #25
+ 'http://www.fda.gov',
+ ]
+ URL = URL_LIST[0]
« no previous file with comments | « tools/perf/contrib/cros_benchmarks/tab_switching_measure.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698