| 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 14 matching lines...) Expand all Loading... |
| 25 Executes the skpbench binary with various configs and skps. | 25 Executes the skpbench binary with various configs and skps. |
| 26 | 26 |
| 27 Also monitors the output in order to filter out and re-run results that have an | 27 Also monitors the output in order to filter out and re-run results that have an |
| 28 unacceptable stddev. | 28 unacceptable stddev. |
| 29 | 29 |
| 30 """) | 30 """) |
| 31 | 31 |
| 32 __argparse.add_argument('--adb', | 32 __argparse.add_argument('--adb', |
| 33 action='store_true', help="execute skpbench over adb") | 33 action='store_true', help="execute skpbench over adb") |
| 34 __argparse.add_argument('-s', '--device-serial', | 34 __argparse.add_argument('-s', '--device-serial', |
| 35 help="if using adb, ID of the specific device to target " | 35 help="if using adb, id of the specific device to target") |
| 36 "(only required if more than 1 device is attached)") | |
| 37 __argparse.add_argument('-p', '--path', | 36 __argparse.add_argument('-p', '--path', |
| 38 help="directory to execute ./skpbench from") | 37 help="directory to execute ./skpbench from") |
| 39 __argparse.add_argument('-m', '--max-stddev', | 38 __argparse.add_argument('-m', '--max-stddev', |
| 40 type=float, default=4, | 39 type=float, default=4, |
| 41 help="initial max allowable relative standard deviation") | 40 help="initial max allowable relative standard deviation") |
| 42 __argparse.add_argument('-x', '--suffix', | 41 __argparse.add_argument('-x', '--suffix', |
| 43 help="suffix to append on config (e.g. '_before', '_after')") | 42 help="suffix to append on config (e.g. '_before', '_after')") |
| 44 __argparse.add_argument('-w','--write-path', | 43 __argparse.add_argument('-w','--write-path', |
| 45 help="directory to save .png proofs to disk.") | 44 help="directory to save .png proofs to disk.") |
| 46 __argparse.add_argument('-v','--verbosity', | 45 __argparse.add_argument('-v','--verbosity', |
| 47 type=int, default=1, help="level of verbosity (0=none to 5=debug)") | 46 type=int, default=1, help="level of verbosity (0=none to 5=debug)") |
| 48 __argparse.add_argument('-d', '--duration', | 47 __argparse.add_argument('-d', '--duration', |
| 49 type=int, help="number of milliseconds to run each benchmark") | 48 type=int, help="number of milliseconds to run each benchmark") |
| 50 __argparse.add_argument('-l', '--sample-ms', | 49 __argparse.add_argument('-l', '--sample-ms', |
| 51 type=int, help="duration of a sample (minimum)") | 50 type=int, help="minimum duration of a sample") |
| 52 __argparse.add_argument('--gpu', | |
| 53 action='store_true', | |
| 54 help="perform timing on the gpu clock instead of cpu (gpu work only)") | |
| 55 __argparse.add_argument('--fps', | 51 __argparse.add_argument('--fps', |
| 56 action='store_true', help="use fps instead of ms") | 52 action='store_true', help="use fps instead of ms") |
| 57 __argparse.add_argument('-c', '--config', | 53 __argparse.add_argument('-c', '--config', |
| 58 default='gpu', help="comma- or space-separated list of GPU configs") | 54 default='gpu', help="comma- or space-separated list of GPU configs") |
| 59 __argparse.add_argument('skps', | 55 __argparse.add_argument('skps', |
| 60 nargs='+', | 56 nargs='+', |
| 61 help=".skp files or directories to expand for .skp files") | 57 help=".skp files or directories to expand for .skp files") |
| 62 | 58 |
| 63 FLAGS = __argparse.parse_args() | 59 FLAGS = __argparse.parse_args() |
| 64 if FLAGS.adb: | 60 if FLAGS.adb: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 for line in iter(self._proc.stdout.readline, b''): | 86 for line in iter(self._proc.stdout.readline, b''): |
| 91 self._queue.put(Message(Message.READLINE, line.decode('utf-8').rstrip())) | 87 self._queue.put(Message(Message.READLINE, line.decode('utf-8').rstrip())) |
| 92 self._queue.put(Message(Message.EXIT)) | 88 self._queue.put(Message(Message.EXIT)) |
| 93 | 89 |
| 94 class SKPBench: | 90 class SKPBench: |
| 95 ARGV = ['skpbench', '--verbosity', str(FLAGS.verbosity)] | 91 ARGV = ['skpbench', '--verbosity', str(FLAGS.verbosity)] |
| 96 if FLAGS.duration: | 92 if FLAGS.duration: |
| 97 ARGV.extend(['--duration', str(FLAGS.duration)]) | 93 ARGV.extend(['--duration', str(FLAGS.duration)]) |
| 98 if FLAGS.sample_ms: | 94 if FLAGS.sample_ms: |
| 99 ARGV.extend(['--sampleMs', str(FLAGS.sample_ms)]) | 95 ARGV.extend(['--sampleMs', str(FLAGS.sample_ms)]) |
| 100 if FLAGS.gpu: | |
| 101 ARGV.extend(['--gpuClock', 'true']) | |
| 102 if FLAGS.fps: | 96 if FLAGS.fps: |
| 103 ARGV.extend(['--fps', 'true']) | 97 ARGV.extend(['--fps', 'true']) |
| 104 if FLAGS.path: | 98 if FLAGS.path: |
| 105 ARGV[0] = _path.join(FLAGS.path, ARGV[0]) | 99 ARGV[0] = _path.join(FLAGS.path, ARGV[0]) |
| 106 if FLAGS.adb: | 100 if FLAGS.adb: |
| 107 if FLAGS.device_serial is None: | 101 if FLAGS.device_serial is None: |
| 108 ARGV = ['adb', 'shell'] + ARGV | 102 ARGV = ['adb', 'shell'] + ARGV |
| 109 else: | 103 else: |
| 110 ARGV = ['adb', '-s', FLAGS.device_serial, 'shell'] + ARGV | 104 ARGV = ['adb', '-s', FLAGS.device_serial, 'shell'] + ARGV |
| 111 | 105 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 elif FLAGS.verbosity >= 2: | 181 elif FLAGS.verbosity >= 2: |
| 188 print("reusing previous result for %s/%s with lower stddev " | 182 print("reusing previous result for %s/%s with lower stddev " |
| 189 "(%s%% instead of %s%%)." % | 183 "(%s%% instead of %s%%)." % |
| 190 (result.config, result.bench, self.best_result.stddev, | 184 (result.config, result.bench, self.best_result.stddev, |
| 191 result.stddev), file=sys.stderr) | 185 result.stddev), file=sys.stderr) |
| 192 if self.max_stddev and self.best_result.stddev > self.max_stddev: | 186 if self.max_stddev and self.best_result.stddev > self.max_stddev: |
| 193 raise StddevException() | 187 raise StddevException() |
| 194 | 188 |
| 195 def terminate(self): | 189 def terminate(self): |
| 196 if self._proc: | 190 if self._proc: |
| 197 self._proc.terminate() | 191 self._proc.kill() |
| 198 self._monitor.join() | 192 self._monitor.join() |
| 199 self._proc.wait() | 193 self._proc.wait() |
| 200 self._proc = None | 194 self._proc = None |
| 201 | 195 |
| 202 | 196 |
| 203 def run_benchmarks(configs, skps, hardware): | 197 def run_benchmarks(configs, skps, hardware): |
| 204 SKPBench.print_header() | 198 SKPBench.print_header() |
| 205 | 199 |
| 206 benches = collections.deque([(skp, config, FLAGS.max_stddev) | 200 benches = collections.deque([(skp, config, FLAGS.max_stddev) |
| 207 for skp in skps | 201 for skp in skps |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 with hardware: | 257 with hardware: |
| 264 if hardware.kick_in_time: | 258 if hardware.kick_in_time: |
| 265 print("sleeping %i seconds to allow hardware settings to kick in..." % | 259 print("sleeping %i seconds to allow hardware settings to kick in..." % |
| 266 hardware.kick_in_time, file=sys.stderr) | 260 hardware.kick_in_time, file=sys.stderr) |
| 267 time.sleep(hardware.kick_in_time) | 261 time.sleep(hardware.kick_in_time) |
| 268 run_benchmarks(configs, skps, hardware) | 262 run_benchmarks(configs, skps, hardware) |
| 269 | 263 |
| 270 | 264 |
| 271 if __name__ == '__main__': | 265 if __name__ == '__main__': |
| 272 main() | 266 main() |
| OLD | NEW |