OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright 2016 Google Inc. | 3 # Copyright 2016 Google Inc. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 | 7 |
8 from __future__ import print_function | 8 from __future__ import print_function |
9 from _adb import Adb | 9 from _adb import Adb |
10 from _benchresult import BenchResult | 10 from _benchresult import BenchResult |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 @classmethod | 117 @classmethod |
118 def print_header(cls): | 118 def print_header(cls): |
119 commandline = cls.ARGV + ['--duration', '0'] | 119 commandline = cls.ARGV + ['--duration', '0'] |
120 dump_commandline_if_verbose(commandline) | 120 dump_commandline_if_verbose(commandline) |
121 subprocess.call(commandline) | 121 subprocess.call(commandline) |
122 | 122 |
123 @classmethod | 123 @classmethod |
124 def run_warmup(cls, warmup_time): | 124 def run_warmup(cls, warmup_time): |
125 if not warmup_time: | 125 if not warmup_time: |
126 return | 126 return |
127 print('running %i second warmup...' % warmup_time) | 127 print('running %i second warmup...' % warmup_time, file=sys.stderr) |
128 commandline = cls.ARGV + ['--duration', str(warmup_time * 1000), | 128 commandline = cls.ARGV + ['--duration', str(warmup_time * 1000), |
129 '--config', 'gpu', | 129 '--config', 'gpu', |
130 '--skp', 'warmup'] | 130 '--skp', 'warmup'] |
131 dump_commandline_if_verbose(commandline) | 131 dump_commandline_if_verbose(commandline) |
132 output = subprocess.check_output(commandline).decode('utf-8') | 132 output = subprocess.check_output(commandline).decode('utf-8') |
133 # validate the warmup run output. | 133 # validate the warmup run output. |
134 for line in output.split('\n'): | 134 for line in output.split('\n'): |
135 match = BenchResult.match(line.rstrip()) | 135 match = BenchResult.match(line.rstrip()) |
136 if match and match.bench == 'warmup': | 136 if match and match.bench == 'warmup': |
137 return | 137 return |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 self._monitor.start() | 173 self._monitor.start() |
174 | 174 |
175 while True: | 175 while True: |
176 message = self._queue.get() | 176 message = self._queue.get() |
177 if message.message == Message.READLINE: | 177 if message.message == Message.READLINE: |
178 result = BenchResult.match(message.value) | 178 result = BenchResult.match(message.value) |
179 if result: | 179 if result: |
180 hardware.sanity_check() | 180 hardware.sanity_check() |
181 self._process_result(result) | 181 self._process_result(result) |
182 else: | 182 else: |
183 print(message.value) | 183 print(message.value, file=sys.stderr) |
184 sys.stdout.flush() | 184 sys.stdout.flush() |
185 continue | 185 continue |
186 if message.message == Message.POLL_HARDWARE: | 186 if message.message == Message.POLL_HARDWARE: |
187 hardware.sanity_check() | 187 hardware.sanity_check() |
188 self._schedule_hardware_poll() | 188 self._schedule_hardware_poll() |
189 continue | 189 continue |
190 if message.message == Message.EXIT: | 190 if message.message == Message.EXIT: |
191 self._monitor.join() | 191 self._monitor.join() |
192 self._proc.wait() | 192 self._proc.wait() |
193 if self._proc.returncode != 0: | 193 if self._proc.returncode != 0: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 print("stddev is too high for %s/%s (%s%%, max=%.2f%%), " | 245 print("stddev is too high for %s/%s (%s%%, max=%.2f%%), " |
246 "re-queuing with max=%.2f%%." % | 246 "re-queuing with max=%.2f%%." % |
247 (skpbench.best_result.config, skpbench.best_result.bench, | 247 (skpbench.best_result.config, skpbench.best_result.bench, |
248 skpbench.best_result.stddev, skpbench.max_stddev, | 248 skpbench.best_result.stddev, skpbench.max_stddev, |
249 retry_max_stddev), | 249 retry_max_stddev), |
250 file=sys.stderr) | 250 file=sys.stderr) |
251 benches.append((skpbench.skp, skpbench.config, retry_max_stddev, | 251 benches.append((skpbench.skp, skpbench.config, retry_max_stddev, |
252 skpbench.best_result)) | 252 skpbench.best_result)) |
253 | 253 |
254 except HardwareException as exception: | 254 except HardwareException as exception: |
| 255 skpbench.terminate() |
255 if FLAGS.verbosity >= 5: | 256 if FLAGS.verbosity >= 5: |
256 hardware.print_debug_diagnostics() | 257 hardware.print_debug_diagnostics() |
257 skpbench.terminate() | |
258 if FLAGS.verbosity >= 1: | 258 if FLAGS.verbosity >= 1: |
259 print("%s; taking a %i second nap..." % | 259 print("%s; taking a %i second nap..." % |
260 (exception.message, exception.sleeptime), file=sys.stderr) | 260 (exception.message, exception.sleeptime), file=sys.stderr) |
261 benches.appendleft(benchargs) # retry the same bench next time. | 261 benches.appendleft(benchargs) # retry the same bench next time. |
262 hardware.sleep(exception.sleeptime) | 262 hardware.sleep(exception.sleeptime) |
| 263 if FLAGS.verbosity >= 5: |
| 264 hardware.print_debug_diagnostics() |
263 SKPBench.run_warmup(hardware.warmup_time) | 265 SKPBench.run_warmup(hardware.warmup_time) |
264 | 266 |
265 | 267 |
266 def main(): | 268 def main(): |
267 # Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)). | 269 # Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)). |
268 DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))' | 270 DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))' |
269 configs = re.split(DELIMITER, FLAGS.config) | 271 configs = re.split(DELIMITER, FLAGS.config) |
270 skps = _path.find_skps(FLAGS.skps) | 272 skps = _path.find_skps(FLAGS.skps) |
271 | 273 |
272 if FLAGS.adb: | 274 if FLAGS.adb: |
273 adb = Adb(FLAGS.device_serial) | 275 adb = Adb(FLAGS.device_serial) |
274 model = adb.get_device_model() | 276 model = adb.get_device_model() |
275 if model == 'Pixel C': | 277 if model == 'Pixel C': |
276 from _hardware_pixel_c import HardwarePixelC | 278 from _hardware_pixel_c import HardwarePixelC |
277 hardware = HardwarePixelC(adb) | 279 hardware = HardwarePixelC(adb) |
| 280 elif model == 'Nexus 6P': |
| 281 from _hardware_nexus_6p import HardwareNexus6P |
| 282 hardware = HardwareNexus6P(adb) |
278 else: | 283 else: |
279 from _hardware_android import HardwareAndroid | 284 from _hardware_android import HardwareAndroid |
280 print("WARNING: %s: don't know how to monitor this hardware; results " | 285 print("WARNING: %s: don't know how to monitor this hardware; results " |
281 "may be unreliable." % model, file=sys.stderr) | 286 "may be unreliable." % model, file=sys.stderr) |
282 hardware = HardwareAndroid(adb) | 287 hardware = HardwareAndroid(adb) |
283 else: | 288 else: |
284 hardware = Hardware() | 289 hardware = Hardware() |
285 | 290 |
286 with hardware: | 291 with hardware: |
287 SKPBench.run_warmup(hardware.warmup_time) | 292 SKPBench.run_warmup(hardware.warmup_time) |
288 run_benchmarks(configs, skps, hardware) | 293 run_benchmarks(configs, skps, hardware) |
289 | 294 |
290 | 295 |
291 if __name__ == '__main__': | 296 if __name__ == '__main__': |
292 main() | 297 main() |
OLD | NEW |