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,61 +136,54 @@ def ParseResult(result_line): ...@@ -137,61 +136,54 @@ 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, to_stdout = output_filename == '-'
wpr_log_path) as wpr_attributes: out = sys.stdout if to_stdout else open(output_filename, 'a')
to_stdout = output_filename == '-' try:
out = sys.stdout if to_stdout else open(output_filename, 'a') while should_stop is None or not should_stop.is_set():
try: config = configs[random.randint(0, len(configs) - 1)]
while should_stop is None or not should_stop.is_set(): chrome_args = chrome_setup.CHROME_ARGS
config = configs[random.randint(0, len(configs) - 1)] if config['speculation_mode'] == 'no_state_prefetch':
chrome_args = chrome_setup.CHROME_ARGS + wpr_attributes.chrome_args # NoStatePrefetch is enabled through an experiment.
if config['speculation_mode'] == 'no_state_prefetch': chrome_args.extend([
# NoStatePrefetch is enabled through an experiment. '--force-fieldtrials=trial/group',
chrome_args.extend([ '--force-fieldtrial-params=trial.group:mode/no_state_prefetch',
'--force-fieldtrials=trial/group', '--enable-features=NoStatePrefetch<trial'])
'--force-fieldtrial-params=trial.group:mode/no_state_prefetch', elif config['speculation_mode'] == 'speculative_prefetch':
'--enable-features=NoStatePrefetch<trial']) # Speculative Prefetch is enabled through an experiment.
elif config['speculation_mode'] == 'speculative_prefetch': chrome_args.extend([
# Speculative Prefetch is enabled through an experiment. '--force-fieldtrials=trial/group',
chrome_args.extend([ '--force-fieldtrial-params=trial.group:mode/external-prefetching',
'--force-fieldtrials=trial/group', '--enable-features=SpeculativeResourcePrefetching<trial'])
'--force-fieldtrial-params=trial.group:mode/external-prefetching',
'--enable-features=SpeculativeResourcePrefetching<trial']) result = RunOnce(device, config['url'], config['speculated_url'],
config['warmup'], config['skip_launcher_activity'],
result = RunOnce(device, config['url'], config['speculated_url'], config['speculation_mode'],
config['warmup'], config['skip_launcher_activity'], config['delay_to_may_launch_url'],
config['speculation_mode'], config['delay_to_launch_url'], config['cold'],
config['delay_to_may_launch_url'], chrome_args, reset_chrome_state=True)
config['delay_to_launch_url'], config['cold'], if result is not None:
chrome_args, reset_chrome_state=True) out.write(result + '\n')
if result is not None: out.flush()
out.write(result + '\n') if once:
out.flush() return
if once: if should_stop is not None:
return should_stop.wait(10.)
if should_stop is not None: else:
should_stop.wait(10.) time.sleep(10)
else: finally:
time.sleep(10) if not to_stdout:
finally: out.close()
if not to_stdout:
out.close()
def ProcessOutput(filename): def ProcessOutput(filename):
...@@ -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