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

Side by Side Diff: components/cronet/android/test/javaperftests/run.py

Issue 1536433002: [Cronet] Get Cronet performance test running again (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ignore netty proguard errors Created 4 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
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 from telemetry import story 59 from telemetry import story
60 from telemetry.internal import forwarders 60 from telemetry.internal import forwarders
61 from telemetry.internal.forwarders import android_forwarder 61 from telemetry.internal.forwarders import android_forwarder
62 from telemetry.value import scalar 62 from telemetry.value import scalar
63 from telemetry.web_perf import timeline_based_measurement 63 from telemetry.web_perf import timeline_based_measurement
64 64
65 BUILD_TYPE = 'Release' 65 BUILD_TYPE = 'Release'
66 BUILD_DIR = os.path.join(REPOSITORY_ROOT, 'out', BUILD_TYPE) 66 BUILD_DIR = os.path.join(REPOSITORY_ROOT, 'out', BUILD_TYPE)
67 QUIC_SERVER = os.path.join(BUILD_DIR, 'quic_server') 67 QUIC_SERVER = os.path.join(BUILD_DIR, 'quic_server')
68 QUIC_CLIENT = os.path.join(BUILD_DIR, 'quic_client') 68 QUIC_CLIENT = os.path.join(BUILD_DIR, 'quic_client')
69 CERT_PATH = os.path.join('net', 'data', 'ssl', 'certificates')
70 QUIC_CERT_DIR = os.path.join(REPOSITORY_ROOT, CERT_PATH)
71 QUIC_CERT_HOST = 'test.example.com'
72 QUIC_CERT_FILENAME = 'quic_%s.crt' % QUIC_CERT_HOST
73 QUIC_CERT = os.path.join(QUIC_CERT_DIR, QUIC_CERT_FILENAME)
74 QUIC_KEY = os.path.join(QUIC_CERT_DIR, 'quic_%s.key.pkcs8' % QUIC_CERT_HOST)
69 APP_APK = os.path.join(BUILD_DIR, 'apks', 'CronetPerfTest.apk') 75 APP_APK = os.path.join(BUILD_DIR, 'apks', 'CronetPerfTest.apk')
70 APP_PACKAGE = 'org.chromium.net' 76 APP_PACKAGE = 'org.chromium.net'
71 APP_ACTIVITY = '.CronetPerfTestActivity' 77 APP_ACTIVITY = '.CronetPerfTestActivity'
72 APP_ACTION = 'android.intent.action.MAIN' 78 APP_ACTION = 'android.intent.action.MAIN'
73 BENCHMARK_CONFIG = { 79 BENCHMARK_CONFIG = {
74 # Control various metric recording for further investigation. 80 # Control various metric recording for further investigation.
75 'CAPTURE_NETLOG': False, 81 'CAPTURE_NETLOG': False,
76 'CAPTURE_TRACE': False, 82 'CAPTURE_TRACE': False,
77 'CAPTURE_SAMPLED_TRACE': False, 83 'CAPTURE_SAMPLED_TRACE': False,
78 # While running Cronet Async API benchmarks, indicate if callbacks should be 84 # While running Cronet Async API benchmarks, indicate if callbacks should be
(...skipping 12 matching lines...) Expand all
91 'LARGE_ITERATIONS': 4, 97 'LARGE_ITERATIONS': 4,
92 # An on-device file containing benchmark timings. Written by benchmark app. 98 # An on-device file containing benchmark timings. Written by benchmark app.
93 'RESULTS_FILE': '/data/data/' + APP_PACKAGE + '/results.txt', 99 'RESULTS_FILE': '/data/data/' + APP_PACKAGE + '/results.txt',
94 # An on-device file whose presence indicates benchmark app has terminated. 100 # An on-device file whose presence indicates benchmark app has terminated.
95 'DONE_FILE': '/data/data/' + APP_PACKAGE + '/done.txt', 101 'DONE_FILE': '/data/data/' + APP_PACKAGE + '/done.txt',
96 # Ports of HTTP and QUIC servers on host. 102 # Ports of HTTP and QUIC servers on host.
97 'HTTP_PORT': 9000, 103 'HTTP_PORT': 9000,
98 'QUIC_PORT': 9001, 104 'QUIC_PORT': 9001,
99 # Maximum read/write buffer size to use. 105 # Maximum read/write buffer size to use.
100 'MAX_BUFFER_SIZE': 16384, 106 'MAX_BUFFER_SIZE': 16384,
107 'HOST': QUIC_CERT_HOST,
108 'QUIC_CERT_FILE': QUIC_CERT_FILENAME,
101 } 109 }
102 # Add benchmark config to global state for easy access. 110 # Add benchmark config to global state for easy access.
103 globals().update(BENCHMARK_CONFIG) 111 globals().update(BENCHMARK_CONFIG)
104 112
105 113
106 def GetDevice(): 114 def GetDevice():
107 devices = device_utils.DeviceUtils.HealthyDevices() 115 devices = device_utils.DeviceUtils.HealthyDevices()
108 assert len(devices) == 1 116 assert len(devices) == 1
109 return devices[0] 117 return devices[0]
110 118
(...skipping 12 matching lines...) Expand all
123 131
124 class CronetPerfTestAndroidStory(android.AndroidStory): 132 class CronetPerfTestAndroidStory(android.AndroidStory):
125 # Android AppStory implementation wrapping CronetPerfTest app. 133 # Android AppStory implementation wrapping CronetPerfTest app.
126 # Launches Cronet perf test app and waits for execution to complete 134 # Launches Cronet perf test app and waits for execution to complete
127 # by waiting for presence of DONE_FILE. 135 # by waiting for presence of DONE_FILE.
128 136
129 def __init__(self, device): 137 def __init__(self, device):
130 self._device = device 138 self._device = device
131 device.RunShellCommand('rm %s' % DONE_FILE) 139 device.RunShellCommand('rm %s' % DONE_FILE)
132 config = BENCHMARK_CONFIG 140 config = BENCHMARK_CONFIG
133 config['HOST'] = GetServersHost(device) 141 config['HOST_IP'] = GetServersHost(device)
134 start_intent = intent.Intent( 142 start_intent = intent.Intent(
135 package=APP_PACKAGE, 143 package=APP_PACKAGE,
136 activity=APP_ACTIVITY, 144 activity=APP_ACTIVITY,
137 action=APP_ACTION, 145 action=APP_ACTION,
138 # |config| maps from configuration value names to the configured values. 146 # |config| maps from configuration value names to the configured values.
139 # |config| is encoded as URL parameter names and values and passed to 147 # |config| is encoded as URL parameter names and values and passed to
140 # the Cronet perf test app via the Intent data field. 148 # the Cronet perf test app via the Intent data field.
141 data='http://dummy/?'+urllib.urlencode(config), 149 data='http://dummy/?'+urllib.urlencode(config),
142 extras=None, 150 extras=None,
143 category=None) 151 category=None)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 class QuicServer: 211 class QuicServer:
204 212
205 def __init__(self, quic_server_doc_root): 213 def __init__(self, quic_server_doc_root):
206 self._process = None 214 self._process = None
207 self._quic_server_doc_root = quic_server_doc_root 215 self._quic_server_doc_root = quic_server_doc_root
208 216
209 def StartupQuicServer(self, device): 217 def StartupQuicServer(self, device):
210 self._process = pexpect.spawn(QUIC_SERVER, 218 self._process = pexpect.spawn(QUIC_SERVER,
211 ['--quic_in_memory_cache_dir=%s' % 219 ['--quic_in_memory_cache_dir=%s' %
212 self._quic_server_doc_root, 220 self._quic_server_doc_root,
221 '--certificate_file=%s' % QUIC_CERT,
222 '--key_file=%s' % QUIC_KEY,
213 '--port=%d' % QUIC_PORT]) 223 '--port=%d' % QUIC_PORT])
214 assert self._process != None 224 assert self._process != None
215 # Wait for quic_server to start serving. 225 # Wait for quic_server to start serving.
216 waited_s = 0 226 waited_s = 0
217 while subprocess.call([QUIC_CLIENT, 227 while subprocess.call(['lsof', '-i', 'udp:%d' % QUIC_PORT, '-p',
218 '--host=%s' % GetServersHost(device), 228 '%d' % self._process.pid],
219 '--port=%d' % QUIC_PORT,
220 'http://%s:%d/%s' % (GetServersHost(device),
221 QUIC_PORT, SMALL_RESOURCE)],
222 stdout=open(os.devnull, 'w')) != 0: 229 stdout=open(os.devnull, 'w')) != 0:
223 sleep(0.1) 230 sleep(0.1)
224 waited_s += 0.1 231 waited_s += 0.1
225 assert waited_s < 5, "quic_server failed to start after %fs" % waited_s 232 assert waited_s < 5, "quic_server failed to start after %fs" % waited_s
233 # Push certificate to device.
234 cert = open(QUIC_CERT, 'r').read()
235 device_cert_path = os.path.join(device.GetExternalStoragePath(), CERT_PATH)
236 device.RunShellCommand('mkdir -p %s' % device_cert_path)
237 device.WriteFile(os.path.join(device_cert_path, QUIC_CERT_FILENAME), cert)
226 238
227 def ShutdownQuicServer(self): 239 def ShutdownQuicServer(self):
228 if self._process: 240 if self._process:
229 self._process.terminate() 241 self._process.terminate()
230 242
231 243
232 def GenerateHttpTestResources(): 244 def GenerateHttpTestResources():
233 http_server_doc_root = tempfile.mkdtemp() 245 http_server_doc_root = tempfile.mkdtemp()
234 # Create a small test file to serve. 246 # Create a small test file to serve.
235 small_file_name = os.path.join(http_server_doc_root, SMALL_RESOURCE) 247 small_file_name = os.path.join(http_server_doc_root, SMALL_RESOURCE)
(...skipping 18 matching lines...) Expand all
254 # Use wget to build up fake QUIC in-memory cache dir for serving. 266 # Use wget to build up fake QUIC in-memory cache dir for serving.
255 # quic_server expects the dir/file layout that wget produces. 267 # quic_server expects the dir/file layout that wget produces.
256 for resource in [SMALL_RESOURCE, LARGE_RESOURCE]: 268 for resource in [SMALL_RESOURCE, LARGE_RESOURCE]:
257 assert subprocess.Popen(['wget', '-p', '-q', '--save-headers', 269 assert subprocess.Popen(['wget', '-p', '-q', '--save-headers',
258 GetHttpServerURL(device, resource)], 270 GetHttpServerURL(device, resource)],
259 cwd=quic_server_doc_root).wait() == 0 271 cwd=quic_server_doc_root).wait() == 0
260 # wget places results in host:port directory. Adjust for QUIC port. 272 # wget places results in host:port directory. Adjust for QUIC port.
261 os.rename(os.path.join(quic_server_doc_root, 273 os.rename(os.path.join(quic_server_doc_root,
262 "%s:%d" % (GetServersHost(device), HTTP_PORT)), 274 "%s:%d" % (GetServersHost(device), HTTP_PORT)),
263 os.path.join(quic_server_doc_root, 275 os.path.join(quic_server_doc_root,
264 "%s:%d" % (GetServersHost(device), QUIC_PORT))) 276 "%s:%d" % (QUIC_CERT_HOST, QUIC_PORT)))
265 return quic_server_doc_root 277 return quic_server_doc_root
266 278
267 279
268 def GenerateLighttpdConfig(config_file, http_server_doc_root, http_server): 280 def GenerateLighttpdConfig(config_file, http_server_doc_root, http_server):
269 # Must create customized config file to allow overriding the server.bind 281 # Must create customized config file to allow overriding the server.bind
270 # setting. 282 # setting.
271 config_file.write('server.document-root = "%s"\n' % http_server_doc_root) 283 config_file.write('server.document-root = "%s"\n' % http_server_doc_root)
272 config_file.write('server.port = %d\n' % HTTP_PORT) 284 config_file.write('server.port = %d\n' % HTTP_PORT)
273 # These lines are added so lighttpd_server.py's internal test succeeds. 285 # These lines are added so lighttpd_server.py's internal test succeeds.
274 config_file.write('server.tag = "%s"\n' % http_server.server_tag) 286 config_file.write('server.tag = "%s"\n' % http_server.server_tag)
(...skipping 28 matching lines...) Expand all
303 quic_server.StartupQuicServer(device) 315 quic_server.StartupQuicServer(device)
304 # Launch Telemetry's benchmark_runner on CronetPerfTestBenchmark. 316 # Launch Telemetry's benchmark_runner on CronetPerfTestBenchmark.
305 # By specifying this file's directory as the benchmark directory, it will 317 # By specifying this file's directory as the benchmark directory, it will
306 # allow benchmark_runner to in turn open this file up and find the 318 # allow benchmark_runner to in turn open this file up and find the
307 # CronetPerfTestBenchmark class to run the benchmark. 319 # CronetPerfTestBenchmark class to run the benchmark.
308 top_level_dir = os.path.dirname(os.path.realpath(__file__)) 320 top_level_dir = os.path.dirname(os.path.realpath(__file__))
309 # The perf config file is required to continue using dependencies on the 321 # The perf config file is required to continue using dependencies on the
310 # Chromium checkout in Telemetry. 322 # Chromium checkout in Telemetry.
311 perf_config_file = os.path.join(REPOSITORY_ROOT, 'tools', 'perf', 'core', 323 perf_config_file = os.path.join(REPOSITORY_ROOT, 'tools', 'perf', 'core',
312 'binary_dependencies.json') 324 'binary_dependencies.json')
325 with open(perf_config_file, "w") as config_file:
326 config_file.write('{"config_type": "BaseConfig"}')
313 runner_config = benchmark_runner.ProjectConfig( 327 runner_config = benchmark_runner.ProjectConfig(
314 top_level_dir=top_level_dir, 328 top_level_dir=top_level_dir,
315 benchmark_dirs=[top_level_dir], 329 benchmark_dirs=[top_level_dir],
316 client_config=perf_config_file) 330 client_config=perf_config_file,
331 default_chrome_root=REPOSITORY_ROOT)
317 sys.argv.insert(1, 'run') 332 sys.argv.insert(1, 'run')
318 sys.argv.insert(2, 'run.CronetPerfTestBenchmark') 333 sys.argv.insert(2, 'run.CronetPerfTestBenchmark')
319 sys.argv.insert(3, '--android-rndis') 334 sys.argv.insert(3, '--android-rndis')
320 benchmark_runner.main(runner_config) 335 benchmark_runner.main(runner_config)
321 # Shutdown. 336 # Shutdown.
322 quic_server.ShutdownQuicServer() 337 quic_server.ShutdownQuicServer()
323 shutil.rmtree(quic_server_doc_root) 338 shutil.rmtree(quic_server_doc_root)
324 http_server.ShutdownHttpServer() 339 http_server.ShutdownHttpServer()
325 shutil.rmtree(http_server_doc_root) 340 shutil.rmtree(http_server_doc_root)
326 341
327 342
328 if __name__ == '__main__': 343 if __name__ == '__main__':
329 main() 344 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698