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