Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: tools/resource_prefetch_predictor/prefetch_benchmark.py

Issue 2652313002: predictors: Move the configuration of speculative prefetch to field trials. (Closed)
Patch Set: Address comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/resource_prefetch_predictor/generate_test_data.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2016 The Chromium Authors. All rights reserved. 3 # Copyright 2016 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Loads a web page with speculative prefetch, and collects loading metrics.""" 7 """Loads a web page with speculative prefetch, and collects loading metrics."""
8 8
9 import argparse 9 import argparse
10 import logging 10 import logging
(...skipping 16 matching lines...) Expand all
27 27
28 sys.path.append(os.path.join(_SRC_PATH, 'build', 'android')) 28 sys.path.append(os.path.join(_SRC_PATH, 'build', 'android'))
29 import devil_chromium 29 import devil_chromium
30 30
31 sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'catapult', 'devil')) 31 sys.path.append(os.path.join(_SRC_PATH, 'third_party', 'catapult', 'devil'))
32 from devil.android.sdk import intent 32 from devil.android.sdk import intent
33 33
34 import prefetch_predictor_common 34 import prefetch_predictor_common
35 35
36 36
37 _EXTERNAL_PREFETCH_FLAG = (
38 '--speculative-resource-prefetching=enabled-external-only')
39
40
41 def _CreateArgumentParser(): 37 def _CreateArgumentParser():
42 """Creates and returns the argument parser.""" 38 """Creates and returns the argument parser."""
43 parser = argparse.ArgumentParser( 39 parser = argparse.ArgumentParser(
44 ('Loads a URL with the resource_prefetch_predictor and prints loading ' 40 ('Loads a URL with the resource_prefetch_predictor and prints loading '
45 'metrics.'), parents=[OPTIONS.GetParentParser()]) 41 'metrics.'), parents=[OPTIONS.GetParentParser()])
46 parser.add_argument('--device', help='Device ID') 42 parser.add_argument('--device', help='Device ID')
47 parser.add_argument('--database', 43 parser.add_argument('--database',
48 help=('File containing the predictor database, as ' 44 help=('File containing the predictor database, as '
49 'obtained from generate_database.py.')) 45 'obtained from generate_database.py.'))
50 parser.add_argument('--url', help='URL to load.') 46 parser.add_argument('--url', help='URL to load.')
(...skipping 16 matching lines...) Expand all
67 chrome_package = OPTIONS.ChromePackage() 63 chrome_package = OPTIONS.ChromePackage()
68 device.ForceStop(chrome_package.package) 64 device.ForceStop(chrome_package.package)
69 chrome_controller.ResetBrowserState() 65 chrome_controller.ResetBrowserState()
70 device_database_filename = prefetch_predictor_common.DatabaseDevicePath() 66 device_database_filename = prefetch_predictor_common.DatabaseDevicePath()
71 owner = group = None 67 owner = group = None
72 68
73 # Make sure that the speculative prefetch predictor is enabled to ensure 69 # Make sure that the speculative prefetch predictor is enabled to ensure
74 # that the disk database is re-created. 70 # that the disk database is re-created.
75 command_line_path = '/data/local/tmp/chrome-command-line' 71 command_line_path = '/data/local/tmp/chrome-command-line'
76 with device_setup.FlagReplacer( 72 with device_setup.FlagReplacer(
77 device, command_line_path, ['--disable-fre', _EXTERNAL_PREFETCH_FLAG]): 73 device, command_line_path, ['--disable-fre']):
78 # Launch Chrome for the first time to recreate the local state. 74 # Launch Chrome for the first time to recreate the local state.
79 launch_intent = intent.Intent( 75 launch_intent = intent.Intent(
80 action='android.intent.action.MAIN', 76 action='android.intent.action.MAIN',
81 package=chrome_package.package, 77 package=chrome_package.package,
82 activity=chrome_package.activity) 78 activity=chrome_package.activity)
83 device.StartActivity(launch_intent, blocking=True) 79 device.StartActivity(launch_intent, blocking=True)
84 time.sleep(5) 80 time.sleep(5)
85 device.ForceStop(chrome_package.package) 81 device.ForceStop(chrome_package.package)
86 assert device.FileExists(device_database_filename) 82 assert device.FileExists(device_database_filename)
87 stats = device.StatPath(device_database_filename) 83 stats = device.StatPath(device_database_filename)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 while True: 149 while True:
154 delay = delays[random.randint(0, len(delays) - 1)] 150 delay = delays[random.randint(0, len(delays) - 1)]
155 _RunOnce(device, args.database, args.url, delay, args.output_filename, 151 _RunOnce(device, args.database, args.url, delay, args.output_filename,
156 args.wpr_archive, args.network_condition) 152 args.wpr_archive, args.network_condition)
157 if args.once: 153 if args.once:
158 return 154 return
159 155
160 156
161 if __name__ == '__main__': 157 if __name__ == '__main__':
162 main() 158 main()
OLDNEW
« no previous file with comments | « tools/resource_prefetch_predictor/generate_test_data.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698