def _RunOnce(device, database_filename, url, prefetch_delay_ms, output_filename, wpr_archive, network_condition): _Setup(device, database_filename) disable_prefetch = prefetch_delay_ms == -1 # Startup tracing to ease debugging. chrome_args = (customtabs_benchmark.CHROME_ARGS + ['--trace-startup', '--trace-startup-duration=20']) chrome_controller = controller.RemoteChromeController(device) device.ForceStop(OPTIONS.ChromePackage().package) chrome_controller.AddChromeArguments(chrome_args) with device_setup.RemoteWprHost( device, wpr_archive, record=False, network_condition_name=network_condition) as wpr: logging.info('WPR arguments: ' + ' '.join(wpr.chrome_args)) chrome_args += wpr.chrome_args prefetch_mode = 'disabled' if disable_prefetch else 'speculative_prefetch' result = customtabs_benchmark.RunOnce( device, url, warmup=True, speculation_mode=prefetch_mode, delay_to_may_launch_url=2000, delay_to_launch_url=prefetch_delay_ms, cold=False, chrome_args=chrome_args, reset_chrome_state=False) data_point = customtabs_benchmark.ParseResult(result) with open(output_filename, 'a') as f: f.write(','.join(str(x) for x in data_point) + '\n')
def _Go(device, url, prefetch_delay_ms): disable_prefetch = prefetch_delay_ms == -1 # Startup tracing to ease debugging. chrome_args = (customtabs_benchmark.CHROME_ARGS + ['--trace-startup', '--trace-startup-duration=20']) if not disable_prefetch: chrome_args.append(_EXTERNAL_PREFETCH_FLAG) prefetch_mode = 'disabled' if disable_prefetch else 'speculative_prefetch' result = customtabs_benchmark.RunOnce(device, url, warmup=True, speculation_mode=prefetch_mode, delay_to_may_launch_url=2000, delay_to_launch_url=max( 0, prefetch_delay_ms), cold=False, chrome_args=chrome_args, reset_chrome_state=False) print customtabs_benchmark.ParseResult(result)
def _RunOnDevice(device, output_filename, configs, should_stop): """Loops the tests described by configs on a device. Args: device: (DeviceUtils) device to run the tests on. output_filename: (str) Output file name. configs: (list of dict) List of configurations. should_stop: (Event) When set, this function should return. """ with open(output_filename, 'a') as f: while not should_stop.is_set(): config = configs[random.randint(0, len(configs) - 1)] result = customtabs_benchmark.RunOnce( device, config['url'], config['warmup'], config['no_prerendering'], config['delay_to_may_launch_url'], config['delay_to_launch_url'], config['cold']) if result is not None: f.write(result + '\n') f.flush() should_stop.wait(10.)