Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions | Variables
tools.skpbench.skpbench Namespace Reference

Classes

class  Message
 
class  SKPBench
 
class  StddevException
 
class  SubprocessMonitor
 

Functions

 dump_commandline_if_verbose (commandline)
 
 emit_result (line, resultsfile=None)
 
 run_benchmarks (configs, srcs, hardware, resultsfile=None)
 
 main ()
 

Variables

 help
 
 action
 
 default
 
 type
 
 float
 
 int
 
 nargs
 
 FLAGS = __argparse.parse_args()
 

Function Documentation

◆ dump_commandline_if_verbose()

tools.skpbench.skpbench.dump_commandline_if_verbose (   commandline)

Definition at line 109 of file skpbench.py.

109def dump_commandline_if_verbose(commandline):
110 if FLAGS.verbosity >= 5:
111 quoted = ['\'%s\'' % re.sub(r'([\\\'])', r'\\\1', x) for x in commandline]
112 print(' '.join(quoted), file=sys.stderr)
113
114
void print(void *str)
Definition bridge.cpp:126

◆ emit_result()

tools.skpbench.skpbench.emit_result (   line,
  resultsfile = None 
)

Definition at line 291 of file skpbench.py.

291def emit_result(line, resultsfile=None):
292 print(line)
293 sys.stdout.flush()
294 if resultsfile:
295 print(line, file=resultsfile)
296 resultsfile.flush()
297

◆ main()

tools.skpbench.skpbench.main ( )

Definition at line 347 of file skpbench.py.

347def main():
348 # Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)).
349 DELIMITER = r'[, ](?!(?:[^(]*\‍([^)]*\‍))*[^()]*\‍))'
350 configs = re.split(DELIMITER, FLAGS.config)
351 srcs = _path.find_skps(FLAGS.srcs)
352 assert srcs
353
354
355 if FLAGS.adb:
356 adb = Adb(FLAGS.device_serial, FLAGS.adb_binary,
357 echo=(FLAGS.verbosity >= 5))
358 from _hardware_android import HardwareAndroid
359
360 model = adb.check('getprop ro.product.model').strip()
361 if model == 'Pixel C':
362 from _hardware_pixel_c import HardwarePixelC
363 hardware = HardwarePixelC(adb)
364 elif model == 'Pixel' or model == "Pixel XL":
365 from _hardware_pixel import HardwarePixel
366 hardware = HardwarePixel(adb)
367 elif model == 'Pixel 2':
368 from _hardware_pixel2 import HardwarePixel2
369 hardware = HardwarePixel2(adb)
370 elif model == 'Nexus 6P':
371 from _hardware_nexus_6p import HardwareNexus6P
372 hardware = HardwareNexus6P(adb)
373 else:
374 print("WARNING: %s: don't know how to monitor this hardware; results "
375 "may be unreliable." % model, file=sys.stderr)
376 hardware = HardwareAndroid(adb)
377
378 if FLAGS.lock_clocks:
379 hardware.__enter__()
380 print("Entered benchmarking mode, not running benchmarks. Reboot to restore.");
381 return;
382
383 if FLAGS.clock_speed:
384 hardware.setDesiredClock(FLAGS.clock_speed)
385 else:
386 hardware = Hardware()
387
388 if FLAGS.resultsfile:
389 with open(FLAGS.resultsfile, mode='a+') as resultsfile:
390 run_benchmarks(configs, srcs, hardware, resultsfile=resultsfile)
391 else:
392 run_benchmarks(configs, srcs, hardware)
393
394
Definition main.py:1

◆ run_benchmarks()

tools.skpbench.skpbench.run_benchmarks (   configs,
  srcs,
  hardware,
  resultsfile = None 
)

Definition at line 298 of file skpbench.py.

298def run_benchmarks(configs, srcs, hardware, resultsfile=None):
299 hasheader = False
300 benches = collections.deque([(src, config, FLAGS.max_stddev)
301 for src in srcs
302 for config in configs])
303 while benches:
304 try:
305 with hardware:
306 SKPBench.run_warmup(hardware.warmup_time, configs[0])
307 if not hasheader:
308 emit_result(SKPBench.get_header(), resultsfile)
309 hasheader = True
310 while benches:
311 benchargs = benches.popleft()
312 with SKPBench(*benchargs) as skpbench:
313 try:
314 skpbench.execute(hardware)
315 if skpbench.best_result:
316 emit_result(skpbench.best_result.format(FLAGS.suffix),
317 resultsfile)
318 else:
319 print("WARNING: no result for %s with config %s" %
320 (skpbench.src, skpbench.config), file=sys.stderr)
321
322 except StddevException:
323 retry_max_stddev = skpbench.max_stddev * math.sqrt(2)
324 if FLAGS.verbosity >= 1:
325 print("stddev is too high for %s/%s (%s%%, max=%.2f%%), "
326 "re-queuing with max=%.2f%%." %
327 (skpbench.best_result.config, skpbench.best_result.bench,
328 skpbench.best_result.stddev, skpbench.max_stddev,
329 retry_max_stddev),
330 file=sys.stderr)
331 benches.append((skpbench.src, skpbench.config, retry_max_stddev,
332 skpbench.best_result))
333
334 except HardwareException as exception:
335 skpbench.terminate()
336 if FLAGS.verbosity >= 4:
337 hardware.print_debug_diagnostics()
338 if FLAGS.verbosity >= 1:
339 print("%s; rebooting and taking a %i second nap..." %
340 (exception.message, exception.sleeptime), file=sys.stderr)
341 benches.appendleft(benchargs) # retry the same bench next time.
342 raise # wake hw up from benchmarking mode before the nap.
343
344 except HardwareException as exception:
345 time.sleep(exception.sleeptime)
346

Variable Documentation

◆ action

tools.skpbench.skpbench.action

Definition at line 35 of file skpbench.py.

◆ default

tools.skpbench.skpbench.default

Definition at line 36 of file skpbench.py.

◆ FLAGS

tools.skpbench.skpbench.FLAGS = __argparse.parse_args()

Definition at line 102 of file skpbench.py.

◆ float

tools.skpbench.skpbench.float

Definition at line 42 of file skpbench.py.

◆ help

tools.skpbench.skpbench.help

Definition at line 33 of file skpbench.py.

◆ int

tools.skpbench.skpbench.int

Definition at line 49 of file skpbench.py.

◆ nargs

tools.skpbench.skpbench.nargs

Definition at line 96 of file skpbench.py.

◆ type

tools.skpbench.skpbench.type

Definition at line 42 of file skpbench.py.