| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 the V8 project authors. All rights reserved. | 2 # Copyright 2016 the V8 project authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 ''' | 5 ''' |
| 6 Usage: callstats.py [-h] <command> ... | 6 Usage: callstats.py [-h] <command> ... |
| 7 | 7 |
| 8 Optional arguments: | 8 Optional arguments: |
| 9 -h, --help show this help message and exit | 9 -h, --help show this help message and exit |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 }, timeout); | 119 }, timeout); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 console.log("Ignoring: " + url); | 122 console.log("Ignoring: " + url); |
| 123 }; | 123 }; |
| 124 var sites = | 124 var sites = |
| 125 """, json.dumps(sites), """; | 125 """, json.dumps(sites), """; |
| 126 onLoad(window.location.href); | 126 onLoad(window.location.href); |
| 127 })();""" | 127 })();""" |
| 128 | 128 |
| 129 def get_chrome_flags(js_flags, user_data_dir): | 129 def get_chrome_flags(js_flags, user_data_dir, arg_delimiter=""): |
| 130 return [ | 130 return [ |
| 131 "--no-default-browser-check", | 131 "--no-default-browser-check", |
| 132 "--no-sandbox", | 132 "--no-sandbox", |
| 133 "--disable-translate", | 133 "--disable-translate", |
| 134 "--enable-benchmarking", | 134 "--enable-benchmarking", |
| 135 "--js-flags={}".format(js_flags), | 135 "--enable-stats-table", |
| 136 "--js-flags={}{}{}".format(arg_delimiter, js_flags, arg_delimiter), |
| 136 "--no-first-run", | 137 "--no-first-run", |
| 137 "--user-data-dir={}".format(user_data_dir), | 138 "--user-data-dir={}{}{}".format(arg_delimiter, user_data_dir, |
| 139 arg_delimiter), |
| 138 ] | 140 ] |
| 139 | 141 |
| 140 def get_chrome_replay_flags(args): | 142 def get_chrome_replay_flags(args, arg_delimiter=""): |
| 141 http_port = 4080 + args.port_offset | 143 http_port = 4080 + args.port_offset |
| 142 https_port = 4443 + args.port_offset | 144 https_port = 4443 + args.port_offset |
| 143 return [ | 145 return [ |
| 144 "--host-resolver-rules=MAP *:80 localhost:%s, " \ | 146 "--host-resolver-rules=%sMAP *:80 localhost:%s, " \ |
| 145 "MAP *:443 localhost:%s, " \ | 147 "MAP *:443 localhost:%s, " \ |
| 146 "EXCLUDE localhost" % ( | 148 "EXCLUDE localhost%s" % ( |
| 147 http_port, https_port), | 149 arg_delimiter, http_port, https_port, |
| 150 arg_delimiter), |
| 148 "--ignore-certificate-errors", | 151 "--ignore-certificate-errors", |
| 149 "--disable-seccomp-sandbox", | 152 "--disable-seccomp-sandbox", |
| 150 "--disable-web-security", | 153 "--disable-web-security", |
| 151 "--reduce-security-for-testing", | 154 "--reduce-security-for-testing", |
| 152 "--allow-insecure-localhost", | 155 "--allow-insecure-localhost", |
| 153 ] | 156 ] |
| 154 | 157 |
| 155 def run_site(site, domain, args, timeout=None): | 158 def run_site(site, domain, args, timeout=None): |
| 156 print "="*80 | 159 print "="*80 |
| 157 print "RUNNING DOMAIN %s" % domain | 160 print "RUNNING DOMAIN %s" % domain |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 291 |
| 289 | 292 |
| 290 def do_run_replay_server(args): | 293 def do_run_replay_server(args): |
| 291 sites = read_sites(args) | 294 sites = read_sites(args) |
| 292 print("- " * 40) | 295 print("- " * 40) |
| 293 print("Available URLs:") | 296 print("Available URLs:") |
| 294 for site in sites: | 297 for site in sites: |
| 295 print(" "+site['url']) | 298 print(" "+site['url']) |
| 296 print("- " * 40) | 299 print("- " * 40) |
| 297 print("Launch chromium with the following commands for debugging:") | 300 print("Launch chromium with the following commands for debugging:") |
| 298 flags = get_chrome_flags("'--runtime-call-stats --allow-natives-syntax'", | 301 flags = get_chrome_flags("--runtime-call-stats --allow-natives-syntax", |
| 299 "/var/tmp/`date +%s`") | 302 "/var/tmp/`date +%s`", '"') |
| 300 flags += get_chrome_replay_flags(args) | 303 flags += get_chrome_replay_flags(args, "'") |
| 301 print(" $CHROMIUM_DIR/out/Release/chomium " + (" ".join(flags)) + " <URL>") | 304 print(" $CHROMIUM_DIR/out/Release/chrome " + (" ".join(flags)) + " <URL>") |
| 302 print("- " * 40) | 305 print("- " * 40) |
| 303 replay_server = start_replay_server(args, sites, discard_output=False) | 306 replay_server = start_replay_server(args, sites, discard_output=False) |
| 304 try: | 307 try: |
| 305 replay_server['process'].wait() | 308 replay_server['process'].wait() |
| 306 finally: | 309 finally: |
| 307 stop_replay_server(replay_server) | 310 stop_replay_server(replay_server) |
| 308 | 311 |
| 309 | 312 |
| 310 # Calculate statistics. | 313 # Calculate statistics. |
| 311 | 314 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 args.error("use either option --sites-file or site URLs") | 691 args.error("use either option --sites-file or site URLs") |
| 689 sys.exit(1) | 692 sys.exit(1) |
| 690 elif args.command == "run" and not coexist(args.replay_wpr, args.replay_bin): | 693 elif args.command == "run" and not coexist(args.replay_wpr, args.replay_bin): |
| 691 args.error("options --replay-wpr and --replay-bin must be used together") | 694 args.error("options --replay-wpr and --replay-bin must be used together") |
| 692 sys.exit(1) | 695 sys.exit(1) |
| 693 else: | 696 else: |
| 694 args.func(args) | 697 args.func(args) |
| 695 | 698 |
| 696 if __name__ == "__main__": | 699 if __name__ == "__main__": |
| 697 sys.exit(main()) | 700 sys.exit(main()) |
| OLD | NEW |