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

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
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..38e9bed92971cf15875b50e34714fa58f17c43b2
--- /dev/null
+++ b/tools/perf/contrib/cros_benchmarks/tab_switching_stories.py
@@ -0,0 +1,114 @@
+# 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
+import time
+
+from telemetry.core import exceptions
+from telemetry.page import page as page_module
+from telemetry.page import shared_page_state
+from contrib.cros_benchmarks.cros_utils import SetupKeyDispatch, SwitchTab, NoScreenOff
+
+
+class CrosMultiTabSharedState(shared_page_state.SharedPageState):
+ def __init__(self, test, finder_options, story_set):
+ super(CrosMultiTabSharedState, self).__init__(test,finder_options,
+ story_set)
+ self._results = None
+ SetupKeyDispatch(finder_options.cros_remote)
+
+
+# note: when tab count is high, some tab may be discarded, and the tab
+# context would be invalidated. avoid store tab object for later use.
bccheng 2017/05/19 09:09:14 Capitalize the sentences in comments. For example:
vovoy 2017/05/22 03:54:08 Done.
+class CrosMultiTabStory(page_module.Page):
+ def __init__(self, story_set, tabset_repeat=1):
+ super(CrosMultiTabStory, self).__init__(
+ shared_page_state_class=CrosMultiTabSharedState, page_set=story_set,
+ name=self.NAME, url=self.URL)
+ self._tabset_repeat = tabset_repeat
+
+ def RunNavigateSteps(self, action_runner):
+ # pylint: disable=protected-access
+ NoScreenOff(action_runner.tab.browser._platform_backend)
+
+ 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
+
+ for i, url in enumerate(url_list):
+ try:
+ tabs[i].action_runner.WaitForNetworkQuiescence()
+ except py_utils.TimeoutException:
+ logging.warning('WaitForNetworkQuiescence() timeout, url[%d]: %s'
+ % (i, url))
+ except exceptions.DevtoolsTargetCrashException:
+ logging.warning('got DevtoolsTargetCrashException')
+
+ def RunPageInteractions(self, action_runner):
+ # pylint: disable=protected-access
+ 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)
+ platform_backend = browser._platform_backend
+ for i in range(total_tab_count):
+ SwitchTab(platform_backend)
+ time.sleep(2.0)
+ if i % 10 == 0:
+ print 'switching tab:', i
+
+
+class CrosMultiTabTypical24Story(CrosMultiTabStory):
+ 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]

Powered by Google App Engine
This is Rietveld 408576698