Commit e30a30c4 authored by Matthew Cary's avatar Matthew Cary Committed by Commit Bot

Custom Tabs: remove WPR support from customtabs_benchmark script.

This script used the old python WPR wrapper, which has disappared in
favor of a Go-based server which may or may not be publically
supported (see crbug.com/795229). For the time being, it seems expedient
to just tear out WPR, and hence traffic-shaping, support in the script.

Change-Id: Ia001929a110b580fb35ae0cc2b8f8d7c80154caf
Reviewed-on: https://chromium-review.googlesource.com/829034Reviewed-by: default avatarEgor Pasko <pasko@chromium.org>
Commit-Queue: Egor Pasko <pasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524404}
parent cbd7a670
...@@ -31,7 +31,6 @@ import devil_chromium ...@@ -31,7 +31,6 @@ import devil_chromium
sys.path.append(os.path.join(_SRC_PATH, 'tools', 'android', 'loading')) sys.path.append(os.path.join(_SRC_PATH, 'tools', 'android', 'loading'))
import chrome_setup import chrome_setup
import device_setup
# Local build of Chrome (not Chromium). # Local build of Chrome (not Chromium).
...@@ -137,30 +136,23 @@ def ParseResult(result_line): ...@@ -137,30 +136,23 @@ def ParseResult(result_line):
max(_INVALID_VALUE, int(tokens[8]) - intent_sent_timestamp)) max(_INVALID_VALUE, int(tokens[8]) - intent_sent_timestamp))
def LoopOnDevice(device, configs, output_filename, wpr_archive_path=None, def LoopOnDevice(device, configs, output_filename, once=False,
wpr_record=None, network_condition=None, wpr_log_path=None, should_stop=None):
once=False, should_stop=None):
"""Loops the tests on a device. """Loops the tests on a device.
Args: Args:
device: (DeviceUtils) device to run the tests on. device: (DeviceUtils) device to run the tests on.
configs: ([dict]) configs: ([dict])
output_filename: (str) Output filename. '-' for stdout. output_filename: (str) Output filename. '-' for stdout.
wpr_archive_path: (str) Path to the WPR archive.
wpr_record: (bool) Whether WPR is set to recording.
network_condition: (str) Name of the network configuration for throttling.
wpr_log_path: (str) Path the the WPR log.
once: (bool) Run only once. once: (bool) Run only once.
should_stop: (threading.Event or None) When the event is set, stop looping. should_stop: (threading.Event or None) When the event is set, stop looping.
""" """
with SetupWpr(device, wpr_archive_path, wpr_record, network_condition,
wpr_log_path) as wpr_attributes:
to_stdout = output_filename == '-' to_stdout = output_filename == '-'
out = sys.stdout if to_stdout else open(output_filename, 'a') out = sys.stdout if to_stdout else open(output_filename, 'a')
try: try:
while should_stop is None or not should_stop.is_set(): while should_stop is None or not should_stop.is_set():
config = configs[random.randint(0, len(configs) - 1)] config = configs[random.randint(0, len(configs) - 1)]
chrome_args = chrome_setup.CHROME_ARGS + wpr_attributes.chrome_args chrome_args = chrome_setup.CHROME_ARGS
if config['speculation_mode'] == 'no_state_prefetch': if config['speculation_mode'] == 'no_state_prefetch':
# NoStatePrefetch is enabled through an experiment. # NoStatePrefetch is enabled through an experiment.
chrome_args.extend([ chrome_args.extend([
...@@ -246,42 +238,13 @@ def _CreateOptionParser(): ...@@ -246,42 +238,13 @@ def _CreateOptionParser():
parser.add_option('--cold', help='Purge the page cache before each run.', parser.add_option('--cold', help='Purge the page cache before each run.',
default=False, action='store_true') default=False, action='store_true')
parser.add_option('--output_file', help='Output file (append). "-" for ' parser.add_option('--output_file', help='Output file (append). "-" for '
'stdout') 'stdout (this is the default)', default='-')
parser.add_option('--once', help='Run only one iteration.', parser.add_option('--once', help='Run only one iteration.',
action='store_true', default=False) action='store_true', default=False)
# WebPageReplay-related options.
group = optparse.OptionGroup(
parser, 'WebPageReplay options',
'Setting any of these enables WebPageReplay.')
group.add_option('--record', help='Record the WPR archive.',
action='store_true', default=False)
group.add_option('--wpr_archive', help='WPR archive path.')
group.add_option('--wpr_log', help='WPR log path.')
group.add_option('--network_condition',
help='Network condition for emulation.')
parser.add_option_group(group)
return parser return parser
@contextlib.contextmanager
def DummyWprHost():
"""Dummy context used to run without WebPageReplay."""
yield device_setup.WprAttribute(chrome_args=[], chrome_env_override={})
def SetupWpr(device, wpr_archive_path, record, network_condition_name,
out_log_path):
"""Sets up the WebPageReplay server if needed."""
if wpr_archive_path or record or network_condition_name or out_log_path:
return device_setup.RemoteWprHost(device, wpr_archive_path, record,
network_condition_name,
out_log_path=out_log_path)
# WebPageReplay disabled.
return DummyWprHost()
def main(): def main():
parser = _CreateOptionParser() parser = _CreateOptionParser()
options, _ = parser.parse_args() options, _ = parser.parse_args()
...@@ -308,9 +271,7 @@ def main(): ...@@ -308,9 +271,7 @@ def main():
'delay_to_launch_url': options.delay_to_launch_url, 'delay_to_launch_url': options.delay_to_launch_url,
'cold': options.cold, 'cold': options.cold,
} }
LoopOnDevice(device, [config], options.output_file, options.wpr_archive, LoopOnDevice(device, [config], options.output_file, once=options.once)
options.record, options.network_condition, options.wpr_log,
once=options.once)
if __name__ == '__main__': if __name__ == '__main__':
......
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