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

Side by Side Diff: tools/skpbench/skpbench.py

Issue 2481413003: skpbench: simplify adb and reduce number of invocations (Closed)
Patch Set: skpbench: simplify adb and reduce number of invocations Created 4 years, 1 month 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
« no previous file with comments | « tools/skpbench/_hardware_pixel_c.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 help=".skp files or directories to expand for .skp files") 61 help=".skp files or directories to expand for .skp files")
62 62
63 FLAGS = __argparse.parse_args() 63 FLAGS = __argparse.parse_args()
64 if FLAGS.adb: 64 if FLAGS.adb:
65 import _adb_path as _path 65 import _adb_path as _path
66 _path.init(FLAGS.device_serial) 66 _path.init(FLAGS.device_serial)
67 else: 67 else:
68 import _os_path as _path 68 import _os_path as _path
69 69
70 def dump_commandline_if_verbose(commandline): 70 def dump_commandline_if_verbose(commandline):
71 if FLAGS.verbosity >= 4: 71 if FLAGS.verbosity >= 5:
72 quoted = ['\'%s\'' % re.sub(r'([\\\'])', r'\\\1', x) for x in commandline] 72 quoted = ['\'%s\'' % re.sub(r'([\\\'])', r'\\\1', x) for x in commandline]
73 print(' '.join(quoted), file=sys.stderr) 73 print(' '.join(quoted), file=sys.stderr)
74 74
75 75
76 class StddevException(Exception): 76 class StddevException(Exception):
77 pass 77 pass
78 78
79 class Message: 79 class Message:
80 READLINE = 0, 80 READLINE = 0,
81 POLL_HARDWARE = 1, 81 POLL_HARDWARE = 1,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 skpbench.terminate()
256 if FLAGS.verbosity >= 5: 256 if FLAGS.verbosity >= 4:
257 hardware.print_debug_diagnostics() 257 hardware.print_debug_diagnostics()
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: 263 if FLAGS.verbosity >= 4:
264 hardware.print_debug_diagnostics() 264 hardware.print_debug_diagnostics()
265 SKPBench.run_warmup(hardware.warmup_time) 265 SKPBench.run_warmup(hardware.warmup_time)
266 266
267 267
268 def main(): 268 def main():
269 # 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)).
270 DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))' 270 DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
271 configs = re.split(DELIMITER, FLAGS.config) 271 configs = re.split(DELIMITER, FLAGS.config)
272 skps = _path.find_skps(FLAGS.skps) 272 skps = _path.find_skps(FLAGS.skps)
273 273
274 if FLAGS.adb: 274 if FLAGS.adb:
275 adb = Adb(FLAGS.device_serial) 275 adb = Adb(FLAGS.device_serial,
276 model = adb.get_device_model() 276 echofile=(sys.stderr if FLAGS.verbosity >= 5 else None))
277 model = adb.check('getprop ro.product.model').strip()
277 if model == 'Pixel C': 278 if model == 'Pixel C':
278 from _hardware_pixel_c import HardwarePixelC 279 from _hardware_pixel_c import HardwarePixelC
279 hardware = HardwarePixelC(adb) 280 hardware = HardwarePixelC(adb)
280 elif model == 'Nexus 6P': 281 elif model == 'Nexus 6P':
281 from _hardware_nexus_6p import HardwareNexus6P 282 from _hardware_nexus_6p import HardwareNexus6P
282 hardware = HardwareNexus6P(adb) 283 hardware = HardwareNexus6P(adb)
283 else: 284 else:
284 from _hardware_android import HardwareAndroid 285 from _hardware_android import HardwareAndroid
285 print("WARNING: %s: don't know how to monitor this hardware; results " 286 print("WARNING: %s: don't know how to monitor this hardware; results "
286 "may be unreliable." % model, file=sys.stderr) 287 "may be unreliable." % model, file=sys.stderr)
287 hardware = HardwareAndroid(adb) 288 hardware = HardwareAndroid(adb)
288 else: 289 else:
289 hardware = Hardware() 290 hardware = Hardware()
290 291
291 with hardware: 292 with hardware:
292 SKPBench.run_warmup(hardware.warmup_time) 293 SKPBench.run_warmup(hardware.warmup_time)
293 run_benchmarks(configs, skps, hardware) 294 run_benchmarks(configs, skps, hardware)
294 295
295 296
296 if __name__ == '__main__': 297 if __name__ == '__main__':
297 main() 298 main()
OLDNEW
« no previous file with comments | « tools/skpbench/_hardware_pixel_c.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698