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 testParsePartialResult(self): result_line = ("1,0,disabled,1000,3000,510998167,-1,-1,510999329") result = customtabs_benchmark.ParseResult(result_line) self.assertEquals(1, result.warmup) self.assertEquals(0, result.skip_launcher_activity) self.assertEquals('disabled', result.speculation_mode) self.assertEquals(1000, result.delay_to_may_launch_url) self.assertEquals(3000, result.delay_to_launch_url) self.assertEquals(-1, result.commit) self.assertEquals(-1, result.plt) self.assertEquals(510999329 - 510998167, result.first_contentful_paint)
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)