Commit 38af6b5f authored by Egor Pasko's avatar Egor Pasko Committed by Commit Bot

Enable WPR for benchmarks/startup_mobile.py

Coding against this API has been a 2-day debugging challenge :)

I also considered "moving network controller options out of
browser_options into finder_options: [1]. Then quickly I was chasing the
ideals of unbundling StorySet from WprArchiveInfo in order to make
_possible_browser.{SetUp,CleanUp}Environment() to start/stop the WPR
server and forwarding.

This would have been a better API IMO. On the other hand the refactoring
associated with it looked a bit involved. So here it is - re-elly
partial solution, to say mildly, which injects a few more
tightly-coupled classes into each other to solve one specific problem.
Sorry.

[1] Mention of http://crbug.com/404771 in shared_page_state.py. The
    catapult side of it
    (https://github.com/catapult-project/catapult/issues/1977) was
    closed, but seems not done yet.

Bug: 760498
Change-Id: I44e03179f9f2ed16f8fc1934c9786ef342f83609
Reviewed-on: https://chromium-review.googlesource.com/1122862
Commit-Queue: Egor Pasko <pasko@chromium.org>
Reviewed-by: default avatarJuan Antonio Navarro Pérez <perezju@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572276}
parent 3ec692ce
...@@ -33,11 +33,8 @@ from devil.android.sdk import intent # pylint: disable=import-error ...@@ -33,11 +33,8 @@ from devil.android.sdk import intent # pylint: disable=import-error
# iterations as needed without being affected by pageset-repeat being set by # iterations as needed without being affected by pageset-repeat being set by
# bisect/Pinpoint. # bisect/Pinpoint.
# #
# Note: this benchmark is not yet ready for FYI bots because: # Note: this benchmark is not yet ready for FYI bots. When we ensure that
# 1. The requests are not routed through WPR yet. # evicting OS pagecache happens at proper times, we will replace
# 2. The benchmark is not yet careful with evicting OS pagecache at proper
# times.
# As soon as these two functions are implemented, we will replace
# 'experimental.startup.android.coldish' with 'experimental.startup.mobile'. # 'experimental.startup.android.coldish' with 'experimental.startup.mobile'.
# After adding warm starts the resulting benchmark can replace the # After adding warm starts the resulting benchmark can replace the
# 'start_with_url.*' family that has aged quite a bit. # 'start_with_url.*' family that has aged quite a bit.
...@@ -61,15 +58,12 @@ class _MobileStartupSharedState(story_module.SharedState): ...@@ -61,15 +58,12 @@ class _MobileStartupSharedState(story_module.SharedState):
self._finder_options = finder_options self._finder_options = finder_options
self._possible_browser = browser_finder.FindBrowser(self._finder_options) self._possible_browser = browser_finder.FindBrowser(self._finder_options)
self._current_story = None self._current_story = None
# Allow using this shared state only on Android.
# This is an Android-only shared state.
assert isinstance(self.platform, android_platform.AndroidPlatform) assert isinstance(self.platform, android_platform.AndroidPlatform)
self._finder_options.browser_options.browser_user_agent_type = 'mobile' self._finder_options.browser_options.browser_user_agent_type = 'mobile'
# TODO(pasko): This will always use live sites. Should use options to
# configure network_controller properly. See e.g.: https://goo.gl/nAsyFr
self.platform.network_controller.Open(wpr_modes.WPR_OFF)
self.platform.Initialize() self.platform.Initialize()
self.platform.network_controller.Open(wpr_modes.WPR_REPLAY)
self._story_set = story_set
@property @property
def platform(self): def platform(self):
...@@ -109,8 +103,10 @@ class _MobileStartupSharedState(story_module.SharedState): ...@@ -109,8 +103,10 @@ class _MobileStartupSharedState(story_module.SharedState):
self.CloseBrowser(browser) self.CloseBrowser(browser)
def WillRunStory(self, story): def WillRunStory(self, story):
# TODO(pasko): Should start replay to use WPR recordings. self.platform.network_controller.StartReplay(
# See e.g.: https://goo.gl/UJuu8a self._story_set.WprFilePathForStory(story))
# Note: There is no need in StopReplay(), the |network_controller| will do
# it on Close().
self._possible_browser.SetUpEnvironment( self._possible_browser.SetUpEnvironment(
self._finder_options.browser_options) self._finder_options.browser_options)
self._current_story = story self._current_story = story
...@@ -136,7 +132,6 @@ class _MobileStartupSharedState(story_module.SharedState): ...@@ -136,7 +132,6 @@ class _MobileStartupSharedState(story_module.SharedState):
# that occur when closing the browser while tracing is running. When the # that occur when closing the browser while tracing is running. When the
# linked bug is fixed, it should be possible to replace this with just # linked bug is fixed, it should be possible to replace this with just
# browser.Close(). # browser.Close().
try: try:
# a) Explicitly call flush tracing so that we retain a copy of the # a) Explicitly call flush tracing so that we retain a copy of the
# trace from this browser before it's closed. # trace from this browser before it's closed.
...@@ -159,6 +154,9 @@ class _MobileStartupWithIntentStory(story_module.Story): ...@@ -159,6 +154,9 @@ class _MobileStartupWithIntentStory(story_module.Story):
self._action_runner = None self._action_runner = None
def Run(self, state): def Run(self, state):
"""Drives the benchmark with repetitions."""
# TODO(pasko): Find a way to fail the benchmark when WPR is set up
# incorrectly and error pages get loaded.
for _ in xrange(10): for _ in xrange(10):
state.LaunchBrowser('http://bbc.co.uk') state.LaunchBrowser('http://bbc.co.uk')
with state.FindBrowser() as browser: with state.FindBrowser() as browser:
...@@ -168,7 +166,9 @@ class _MobileStartupWithIntentStory(story_module.Story): ...@@ -168,7 +166,9 @@ class _MobileStartupWithIntentStory(story_module.Story):
class _MobileStartupStorySet(story_module.StorySet): class _MobileStartupStorySet(story_module.StorySet):
def __init__(self): def __init__(self):
super(_MobileStartupStorySet, self).__init__() super(_MobileStartupStorySet, self).__init__(
archive_data_file='../page_sets/data/startup_pages.json',
cloud_storage_bucket=story_module.PARTNER_BUCKET)
self.AddStory(_MobileStartupWithIntentStory()) self.AddStory(_MobileStartupWithIntentStory())
......
{ {
"archives": { "archives": {
"intent:coldish:bbc": {
"DEFAULT": "startup_pages_000.wprgo"
},
"http://bbc.co.uk": { "http://bbc.co.uk": {
"DEFAULT": "startup_pages_000.wprgo" "DEFAULT": "startup_pages_000.wprgo"
}, },
...@@ -9,4 +12,4 @@ ...@@ -9,4 +12,4 @@
}, },
"description": "Describes the Web Page Replay archives for a story set. Don't edit by hand! Use record_wpr for updating.", "description": "Describes the Web Page Replay archives for a story set. Don't edit by hand! Use record_wpr for updating.",
"platform_specific": true "platform_specific": true
} }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment