Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
tools.skpbench.skpbench.SKPBench Class Reference

Public Member Functions

 get_header (cls, outfile=sys.stdout)
 
 run_warmup (cls, warmup_time, config)
 
 __init__ (self, src, config, max_stddev, best_result=None)
 
 __enter__ (self)
 
 __exit__ (self, exception_type, exception_value, traceback)
 
 execute (self, hardware)
 
 terminate (self)
 

Public Attributes

 src
 
 config
 
 max_stddev
 
 best_result
 

Static Public Attributes

list ARGV = [FLAGS.skpbench, '--verbosity', str(FLAGS.verbosity)]
 

Protected Member Functions

 _schedule_hardware_poll (self)
 
 _process_result (self, result)
 

Protected Attributes

 _queue
 
 _proc
 
 _monitor
 
 _hw_poll_timer
 

Detailed Description

Definition at line 138 of file skpbench.py.

Constructor & Destructor Documentation

◆ __init__()

tools.skpbench.skpbench.SKPBench.__init__ (   self,
  src,
  config,
  max_stddev,
  best_result = None 
)

Definition at line 207 of file skpbench.py.

207 def __init__(self, src, config, max_stddev, best_result=None):
208 self.src = src
209 self.config = config
210 self.max_stddev = max_stddev
211 self.best_result = best_result
212 self._queue = Queue()
213 self._proc = None
214 self._monitor = None
215 self._hw_poll_timer = None
216

Member Function Documentation

◆ __enter__()

tools.skpbench.skpbench.SKPBench.__enter__ (   self)

Definition at line 217 of file skpbench.py.

217 def __enter__(self):
218 return self
219

◆ __exit__()

tools.skpbench.skpbench.SKPBench.__exit__ (   self,
  exception_type,
  exception_value,
  traceback 
)

Definition at line 220 of file skpbench.py.

220 def __exit__(self, exception_type, exception_value, traceback):
221 if self._proc:
222 self.terminate()
223 if self._hw_poll_timer:
224 self._hw_poll_timer.cancel()
225

◆ _process_result()

tools.skpbench.skpbench.SKPBench._process_result (   self,
  result 
)
protected

Definition at line 273 of file skpbench.py.

273 def _process_result(self, result):
274 if not self.best_result or result.stddev <= self.best_result.stddev:
275 self.best_result = result
276 elif FLAGS.verbosity >= 2:
277 print("reusing previous result for %s/%s with lower stddev "
278 "(%s%% instead of %s%%)." %
279 (result.config, result.bench, self.best_result.stddev,
280 result.stddev), file=sys.stderr)
281 if self.max_stddev and self.best_result.stddev > self.max_stddev:
282 raise StddevException()
283
void print(void *str)
Definition bridge.cpp:126

◆ _schedule_hardware_poll()

tools.skpbench.skpbench.SKPBench._schedule_hardware_poll (   self)
protected

Definition at line 266 of file skpbench.py.

266 def _schedule_hardware_poll(self):
267 if self._hw_poll_timer:
268 self._hw_poll_timer.cancel()
269 self._hw_poll_timer = \
270 Timer(1, lambda: self._queue.put(Message(Message.POLL_HARDWARE)))
271 self._hw_poll_timer.start()
272

◆ execute()

tools.skpbench.skpbench.SKPBench.execute (   self,
  hardware 
)

Definition at line 226 of file skpbench.py.

226 def execute(self, hardware):
227 hardware.sanity_check()
228 self._schedule_hardware_poll()
229
230 commandline = self.ARGV + ['--config', self.config,
231 '--src', self.src,
232 '--suppressHeader', 'true']
233 if FLAGS.write_path:
234 pngfile = _path.join(FLAGS.write_path, self.config,
235 _path.basename(self.src) + '.png')
236 commandline.extend(['--png', pngfile])
237 dump_commandline_if_verbose(commandline)
238 self._proc = subprocess.Popen(commandline, stdout=subprocess.PIPE,
239 stderr=subprocess.STDOUT)
240 self._monitor = SubprocessMonitor(self._queue, self._proc)
241 self._monitor.start()
242
243 while True:
244 message = self._queue.get()
245 if message.message == Message.READLINE:
246 result = BenchResult.match(message.value)
247 if result:
248 hardware.sanity_check()
249 self._process_result(result)
250 elif hardware.filter_line(message.value):
251 print(message.value, file=sys.stderr)
252 continue
253 if message.message == Message.POLL_HARDWARE:
254 hardware.sanity_check()
255 self._schedule_hardware_poll()
256 continue
257 if message.message == Message.EXIT:
258 self._monitor.join()
259 self._proc.wait()
260 if self._proc.returncode != 0:
261 raise Exception("skpbench exited with nonzero exit code %i" %
262 self._proc.returncode)
263 self._proc = None
264 break
265

◆ get_header()

tools.skpbench.skpbench.SKPBench.get_header (   cls,
  outfile = sys.stdout 
)

Definition at line 183 of file skpbench.py.

183 def get_header(cls, outfile=sys.stdout):
184 commandline = cls.ARGV + ['--duration', '0']
185 dump_commandline_if_verbose(commandline)
186 out = subprocess.check_output(commandline, stderr=subprocess.STDOUT, encoding='utf-8')
187 return out.rstrip()
188

◆ run_warmup()

tools.skpbench.skpbench.SKPBench.run_warmup (   cls,
  warmup_time,
  config 
)

Definition at line 190 of file skpbench.py.

190 def run_warmup(cls, warmup_time, config):
191 if not warmup_time:
192 return
193 print('running %i second warmup...' % warmup_time, file=sys.stderr)
194 commandline = cls.ARGV + ['--duration', str(warmup_time * 1000),
195 '--config', config,
196 '--src', 'warmup']
197 dump_commandline_if_verbose(commandline)
198 output = subprocess.check_output(commandline, stderr=subprocess.STDOUT, encoding='utf-8')
199
200 # validate the warmup run output.
201 for line in output.split('\n'):
202 match = BenchResult.match(line.rstrip())
203 if match and match.bench == 'warmup':
204 return
205 raise Exception('Invalid warmup output:\n%s' % output)
206

◆ terminate()

tools.skpbench.skpbench.SKPBench.terminate (   self)

Definition at line 284 of file skpbench.py.

284 def terminate(self):
285 if self._proc:
286 self._proc.terminate()
287 self._monitor.join()
288 self._proc.wait()
289 self._proc = None
290

Member Data Documentation

◆ _hw_poll_timer

tools.skpbench.skpbench.SKPBench._hw_poll_timer
protected

Definition at line 215 of file skpbench.py.

◆ _monitor

tools.skpbench.skpbench.SKPBench._monitor
protected

Definition at line 214 of file skpbench.py.

◆ _proc

tools.skpbench.skpbench.SKPBench._proc
protected

Definition at line 213 of file skpbench.py.

◆ _queue

tools.skpbench.skpbench.SKPBench._queue
protected

Definition at line 212 of file skpbench.py.

◆ ARGV

list tools.skpbench.skpbench.SKPBench.ARGV = [FLAGS.skpbench, '--verbosity', str(FLAGS.verbosity)]
static

Definition at line 139 of file skpbench.py.

◆ best_result

tools.skpbench.skpbench.SKPBench.best_result

Definition at line 211 of file skpbench.py.

◆ config

tools.skpbench.skpbench.SKPBench.config

Definition at line 209 of file skpbench.py.

◆ max_stddev

tools.skpbench.skpbench.SKPBench.max_stddev

Definition at line 210 of file skpbench.py.

◆ src

tools.skpbench.skpbench.SKPBench.src

Definition at line 208 of file skpbench.py.


The documentation for this class was generated from the following file: