OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium 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 """This script runs an automated Cronet performance benchmark. | 6 """This script runs an automated Cronet performance benchmark. |
7 | 7 |
8 This script: | 8 This script: |
9 1. Sets up "USB reverse tethering" which allow network traffic to flow from | 9 1. Sets up "USB reverse tethering" which allow network traffic to flow from |
10 an Android device connected to the host machine via a USB cable. | 10 an Android device connected to the host machine via a USB cable. |
11 2. Starts HTTP and QUIC servers on the host machine. | 11 2. Starts HTTP and QUIC servers on the host machine. |
12 3. Installs an Android app on the attached Android device and runs it. | 12 3. Installs an Android app on the attached Android device and runs it. |
13 4. Collects the results from the app. | 13 4. Collects the results from the app. |
14 | 14 |
15 Prerequisites: | 15 Prerequisites: |
16 1. A rooted (i.e. "adb root" succeeds) Android device connected via a USB cable | 16 1. A rooted (i.e. "adb root" succeeds) Android device connected via a USB cable |
17 to the host machine (i.e. the computer running this script). | 17 to the host machine (i.e. the computer running this script). |
18 2. quic_server has been built for the host machine, e.g. via: | 18 2. quic_server has been built for the host machine, e.g. via: |
19 gn gen out/Release --args="is_debug=false" | 19 gn gen out/Release --args="is_debug=false" |
20 ninja -C out/Release quic_server | 20 ninja -C out/Release quic_server |
21 3. cronet_perf_test_apk has been built for the Android device, e.g. via: | 21 3. cronet_perf_test_apk has been built for the Android device, e.g. via: |
22 ./components/cronet/tools/cr_cronet.py gn -r | 22 ./components/cronet/tools/cr_cronet.py gn -r |
23 ninja -C out/Release cronet_perf_test_apk | 23 ninja -C out/Release cronet_perf_test_apk |
| 24 4. If "sudo ufw status" doesn't say "Status: inactive", run "sudo ufw disable". |
| 25 5. sudo apt-get install lighttpd |
| 26 6. If the usb0 interface on the host keeps losing it's IPv4 address |
| 27 (WaitFor(HasHostAddress) will keep failing), NetworkManager may need to be |
| 28 told to leave usb0 alone with these commands: |
| 29 sudo bash -c "printf \"\\n[keyfile]\ |
| 30 \\nunmanaged-devices=interface-name:usb0\\n\" \ |
| 31 >> /etc/NetworkManager/NetworkManager.conf" |
| 32 sudo service network-manager restart |
24 | 33 |
25 Invocation: | 34 Invocation: |
26 ./run.py | 35 ./run.py |
27 | 36 |
28 Output: | 37 Output: |
29 Benchmark timings are output by telemetry to stdout and written to | 38 Benchmark timings are output by telemetry to stdout and written to |
30 ./results.html | 39 ./results.html |
31 | 40 |
32 """ | 41 """ |
33 | 42 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 226 |
218 def __init__(self, quic_server_doc_root): | 227 def __init__(self, quic_server_doc_root): |
219 self._process = None | 228 self._process = None |
220 self._quic_server_doc_root = quic_server_doc_root | 229 self._quic_server_doc_root = quic_server_doc_root |
221 | 230 |
222 def StartupQuicServer(self, device): | 231 def StartupQuicServer(self, device): |
223 # Chromium's presubmit checks aren't smart enough to understand | 232 # Chromium's presubmit checks aren't smart enough to understand |
224 # the redirect done in build/android/pylib/pexpect.py. | 233 # the redirect done in build/android/pylib/pexpect.py. |
225 # pylint: disable=no-member | 234 # pylint: disable=no-member |
226 self._process = pexpect.spawn(QUIC_SERVER, | 235 self._process = pexpect.spawn(QUIC_SERVER, |
227 ['--quic_in_memory_cache_dir=%s' % | 236 ['--quic_response_cache_dir=%s' % |
228 self._quic_server_doc_root, | 237 self._quic_server_doc_root, |
229 '--certificate_file=%s' % QUIC_CERT, | 238 '--certificate_file=%s' % QUIC_CERT, |
230 '--key_file=%s' % QUIC_KEY, | 239 '--key_file=%s' % QUIC_KEY, |
231 '--port=%d' % QUIC_PORT]) | 240 '--port=%d' % QUIC_PORT]) |
232 assert self._process != None | 241 assert self._process != None |
233 # Wait for quic_server to start serving. | 242 # Wait for quic_server to start serving. |
234 waited_s = 0 | 243 waited_s = 0 |
235 while subprocess.call(['lsof', '-i', 'udp:%d' % QUIC_PORT, '-p', | 244 while subprocess.call(['lsof', '-i', 'udp:%d' % QUIC_PORT, '-p', |
236 '%d' % self._process.pid], | 245 '%d' % self._process.pid], |
237 stdout=open(os.devnull, 'w')) != 0: | 246 stdout=open(os.devnull, 'w')) != 0: |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 benchmark_runner.main(runner_config) | 349 benchmark_runner.main(runner_config) |
341 # Shutdown. | 350 # Shutdown. |
342 quic_server.ShutdownQuicServer() | 351 quic_server.ShutdownQuicServer() |
343 shutil.rmtree(quic_server_doc_root) | 352 shutil.rmtree(quic_server_doc_root) |
344 http_server.ShutdownHttpServer() | 353 http_server.ShutdownHttpServer() |
345 shutil.rmtree(http_server_doc_root) | 354 shutil.rmtree(http_server_doc_root) |
346 | 355 |
347 | 356 |
348 if __name__ == '__main__': | 357 if __name__ == '__main__': |
349 main() | 358 main() |
OLD | NEW |