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

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

Issue 2488043003: skpbench: filter out junk spewed by Pixel C driver (Closed)
Patch Set: 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, file=sys.stderr) 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, stderr=subprocess.STDOUT)
133
133 # validate the warmup run output. 134 # validate the warmup run output.
134 for line in output.split('\n'): 135 for line in output.decode('utf-8').split('\n'):
135 match = BenchResult.match(line.rstrip()) 136 match = BenchResult.match(line.rstrip())
136 if match and match.bench == 'warmup': 137 if match and match.bench == 'warmup':
137 return 138 return
138 raise Exception('Invalid warmup output:\n%s' % output) 139 raise Exception('Invalid warmup output:\n%s' % output)
139 140
140 def __init__(self, skp, config, max_stddev, best_result=None): 141 def __init__(self, skp, config, max_stddev, best_result=None):
141 self.skp = skp 142 self.skp = skp
142 self.config = config 143 self.config = config
143 self.max_stddev = max_stddev 144 self.max_stddev = max_stddev
144 self.best_result = best_result 145 self.best_result = best_result
(...skipping 16 matching lines...) Expand all
161 self._schedule_hardware_poll() 162 self._schedule_hardware_poll()
162 163
163 commandline = self.ARGV + ['--config', self.config, 164 commandline = self.ARGV + ['--config', self.config,
164 '--skp', self.skp, 165 '--skp', self.skp,
165 '--suppressHeader', 'true'] 166 '--suppressHeader', 'true']
166 if FLAGS.write_path: 167 if FLAGS.write_path:
167 pngfile = _path.join(FLAGS.write_path, self.config, 168 pngfile = _path.join(FLAGS.write_path, self.config,
168 _path.basename(self.skp) + '.png') 169 _path.basename(self.skp) + '.png')
169 commandline.extend(['--png', pngfile]) 170 commandline.extend(['--png', pngfile])
170 dump_commandline_if_verbose(commandline) 171 dump_commandline_if_verbose(commandline)
171 self._proc = subprocess.Popen(commandline, stdout=subprocess.PIPE) 172 self._proc = subprocess.Popen(commandline, stdout=subprocess.PIPE,
173 stderr=subprocess.STDOUT)
172 self._monitor = SubprocessMonitor(self._queue, self._proc) 174 self._monitor = SubprocessMonitor(self._queue, self._proc)
173 self._monitor.start() 175 self._monitor.start()
174 176
175 while True: 177 while True:
176 message = self._queue.get() 178 message = self._queue.get()
177 if message.message == Message.READLINE: 179 if message.message == Message.READLINE:
178 result = BenchResult.match(message.value) 180 result = BenchResult.match(message.value)
179 if result: 181 if result:
180 hardware.sanity_check() 182 hardware.sanity_check()
181 self._process_result(result) 183 self._process_result(result)
182 else: 184 elif hardware.filter_line(message.value):
183 print(message.value, file=sys.stderr) 185 print(message.value, file=sys.stderr)
184 sys.stdout.flush()
185 continue 186 continue
186 if message.message == Message.POLL_HARDWARE: 187 if message.message == Message.POLL_HARDWARE:
187 hardware.sanity_check() 188 hardware.sanity_check()
188 self._schedule_hardware_poll() 189 self._schedule_hardware_poll()
189 continue 190 continue
190 if message.message == Message.EXIT: 191 if message.message == Message.EXIT:
191 self._monitor.join() 192 self._monitor.join()
192 self._proc.wait() 193 self._proc.wait()
193 if self._proc.returncode != 0: 194 if self._proc.returncode != 0:
194 raise Exception("skpbench exited with nonzero exit code %i" % 195 raise Exception("skpbench exited with nonzero exit code %i" %
195 self._proc.returncode) 196 self._proc.returncode)
196 self._proc = None 197 self._proc = None
197 break 198 break
198 199
199 def _schedule_hardware_poll(self): 200 def _schedule_hardware_poll(self):
200 if self._hw_poll_timer: 201 if self._hw_poll_timer:
201 self._hw_poll_timer.cancel() 202 self._hw_poll_timer.cancel()
202 self._hw_poll_timer = \ 203 self._hw_poll_timer = \
203 Timer(1, lambda: self._queue.put(Message(Message.POLL_HARDWARE))) 204 Timer(1, lambda: self._queue.put(Message(Message.POLL_HARDWARE)))
204 self._hw_poll_timer.start() 205 self._hw_poll_timer.start()
205 206
206 def _process_result(self, result): 207 def _process_result(self, result):
207 if not self.best_result or result.stddev <= self.best_result.stddev: 208 if not self.best_result or result.stddev <= self.best_result.stddev:
208 self.best_result = result 209 self.best_result = result
209 elif FLAGS.verbosity >= 2: 210 elif FLAGS.verbosity >= 2:
210 print("reusing previous result for %s/%s with lower stddev " 211 print("reusing previous result for %s/%s with lower stddev "
211 "(%s%% instead of %s%%)." % 212 "(%s%% instead of %s%%)." %
212 (result.config, result.bench, self.best_result.stddev, 213 (result.config, result.bench, self.best_result.stddev,
213 result.stddev), file=sys.stderr) 214 result.stddev), file=sys.stderr)
215 sys.stdout.flush()
214 if self.max_stddev and self.best_result.stddev > self.max_stddev: 216 if self.max_stddev and self.best_result.stddev > self.max_stddev:
215 raise StddevException() 217 raise StddevException()
216 218
217 def terminate(self): 219 def terminate(self):
218 if self._proc: 220 if self._proc:
219 self._proc.terminate() 221 self._proc.terminate()
220 self._monitor.join() 222 self._monitor.join()
221 self._proc.wait() 223 self._proc.wait()
222 self._proc = None 224 self._proc = None
223 225
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 else: 290 else:
289 hardware = Hardware() 291 hardware = Hardware()
290 292
291 with hardware: 293 with hardware:
292 SKPBench.run_warmup(hardware.warmup_time) 294 SKPBench.run_warmup(hardware.warmup_time)
293 run_benchmarks(configs, skps, hardware) 295 run_benchmarks(configs, skps, hardware)
294 296
295 297
296 if __name__ == '__main__': 298 if __name__ == '__main__':
297 main() 299 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