| 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. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 # Ports of HTTP and QUIC servers on host. | 102 # Ports of HTTP and QUIC servers on host. |
| 103 'HTTP_PORT': 9000, | 103 'HTTP_PORT': 9000, |
| 104 'QUIC_PORT': 9001, | 104 'QUIC_PORT': 9001, |
| 105 # Maximum read/write buffer size to use. | 105 # Maximum read/write buffer size to use. |
| 106 'MAX_BUFFER_SIZE': 16384, | 106 'MAX_BUFFER_SIZE': 16384, |
| 107 'HOST': QUIC_CERT_HOST, | 107 'HOST': QUIC_CERT_HOST, |
| 108 'QUIC_CERT_FILE': QUIC_CERT_FILENAME, | 108 'QUIC_CERT_FILE': QUIC_CERT_FILENAME, |
| 109 } | 109 } |
| 110 # Add benchmark config to global state for easy access. | 110 # Add benchmark config to global state for easy access. |
| 111 globals().update(BENCHMARK_CONFIG) | 111 globals().update(BENCHMARK_CONFIG) |
| 112 | 112 # Pylint doesn't really interpret the file, so it won't find the definitions |
| 113 # added from BENCHMARK_CONFIG, so suppress the undefined variable warning. |
| 114 #pylint: disable=undefined-variable |
| 113 | 115 |
| 114 def GetDevice(): | 116 def GetDevice(): |
| 115 devices = device_utils.DeviceUtils.HealthyDevices() | 117 devices = device_utils.DeviceUtils.HealthyDevices() |
| 116 assert len(devices) == 1 | 118 assert len(devices) == 1 |
| 117 return devices[0] | 119 return devices[0] |
| 118 | 120 |
| 119 | 121 |
| 120 def GetAndroidRndisConfig(device): | 122 def GetAndroidRndisConfig(device): |
| 121 return android_rndis_forwarder.AndroidRndisConfigurator(device) | 123 return android_rndis_forwarder.AndroidRndisConfigurator(device) |
| 122 | 124 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 super(CronetPerfTestBenchmark, self).__init__(max_failures) | 203 super(CronetPerfTestBenchmark, self).__init__(max_failures) |
| 202 self._device = GetDevice() | 204 self._device = GetDevice() |
| 203 | 205 |
| 204 def CreatePageTest(self, options): | 206 def CreatePageTest(self, options): |
| 205 return CronetPerfTestMeasurement(self._device, options) | 207 return CronetPerfTestMeasurement(self._device, options) |
| 206 | 208 |
| 207 def CreateStorySet(self, options): | 209 def CreateStorySet(self, options): |
| 208 return CronetPerfTestStorySet(self._device) | 210 return CronetPerfTestStorySet(self._device) |
| 209 | 211 |
| 210 | 212 |
| 211 class QuicServer: | 213 class QuicServer(object): |
| 212 | 214 |
| 213 def __init__(self, quic_server_doc_root): | 215 def __init__(self, quic_server_doc_root): |
| 214 self._process = None | 216 self._process = None |
| 215 self._quic_server_doc_root = quic_server_doc_root | 217 self._quic_server_doc_root = quic_server_doc_root |
| 216 | 218 |
| 217 def StartupQuicServer(self, device): | 219 def StartupQuicServer(self, device): |
| 218 self._process = pexpect.spawn(QUIC_SERVER, | 220 self._process = pexpect.spawn(QUIC_SERVER, |
| 219 ['--quic_in_memory_cache_dir=%s' % | 221 ['--quic_in_memory_cache_dir=%s' % |
| 220 self._quic_server_doc_root, | 222 self._quic_server_doc_root, |
| 221 '--certificate_file=%s' % QUIC_CERT, | 223 '--certificate_file=%s' % QUIC_CERT, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 246 # Create a small test file to serve. | 248 # Create a small test file to serve. |
| 247 small_file_name = os.path.join(http_server_doc_root, SMALL_RESOURCE) | 249 small_file_name = os.path.join(http_server_doc_root, SMALL_RESOURCE) |
| 248 small_file = open(small_file_name, 'wb') | 250 small_file = open(small_file_name, 'wb') |
| 249 small_file.write('<html><body></body></html>'); | 251 small_file.write('<html><body></body></html>'); |
| 250 small_file.close() | 252 small_file.close() |
| 251 assert SMALL_RESOURCE_SIZE == os.path.getsize(small_file_name) | 253 assert SMALL_RESOURCE_SIZE == os.path.getsize(small_file_name) |
| 252 # Create a large (10MB) test file to serve. | 254 # Create a large (10MB) test file to serve. |
| 253 large_file_name = os.path.join(http_server_doc_root, LARGE_RESOURCE) | 255 large_file_name = os.path.join(http_server_doc_root, LARGE_RESOURCE) |
| 254 large_file = open(large_file_name, 'wb') | 256 large_file = open(large_file_name, 'wb') |
| 255 large_file.write('<html><body>'); | 257 large_file.write('<html><body>'); |
| 256 for i in range(0, 1000000): | 258 for _ in range(0, 1000000): |
| 257 large_file.write('1234567890'); | 259 large_file.write('1234567890'); |
| 258 large_file.write('</body></html>'); | 260 large_file.write('</body></html>'); |
| 259 large_file.close() | 261 large_file.close() |
| 260 assert LARGE_RESOURCE_SIZE == os.path.getsize(large_file_name) | 262 assert LARGE_RESOURCE_SIZE == os.path.getsize(large_file_name) |
| 261 return http_server_doc_root | 263 return http_server_doc_root |
| 262 | 264 |
| 263 | 265 |
| 264 def GenerateQuicTestResources(device): | 266 def GenerateQuicTestResources(device): |
| 265 quic_server_doc_root = tempfile.mkdtemp() | 267 quic_server_doc_root = tempfile.mkdtemp() |
| 266 # Use wget to build up fake QUIC in-memory cache dir for serving. | 268 # Use wget to build up fake QUIC in-memory cache dir for serving. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 benchmark_runner.main(runner_config) | 333 benchmark_runner.main(runner_config) |
| 332 # Shutdown. | 334 # Shutdown. |
| 333 quic_server.ShutdownQuicServer() | 335 quic_server.ShutdownQuicServer() |
| 334 shutil.rmtree(quic_server_doc_root) | 336 shutil.rmtree(quic_server_doc_root) |
| 335 http_server.ShutdownHttpServer() | 337 http_server.ShutdownHttpServer() |
| 336 shutil.rmtree(http_server_doc_root) | 338 shutil.rmtree(http_server_doc_root) |
| 337 | 339 |
| 338 | 340 |
| 339 if __name__ == '__main__': | 341 if __name__ == '__main__': |
| 340 main() | 342 main() |
| OLD | NEW |