| Index: tools/skpbench/skpbench.py
|
| diff --git a/tools/skpbench/skpbench.py b/tools/skpbench/skpbench.py
|
| index 932d8d0461bcf3514056135124868eceedd0a130..9598162693b250087faeca99457a7e196ad312d9 100755
|
| --- a/tools/skpbench/skpbench.py
|
| +++ b/tools/skpbench/skpbench.py
|
| @@ -67,6 +67,11 @@ if FLAGS.adb:
|
| else:
|
| import _os_path as _path
|
|
|
| +def dump_commandline_if_verbose(commandline):
|
| + if FLAGS.verbosity >= 4:
|
| + quoted = ['\'%s\'' % re.sub(r'([\\\'])', r'\\\1', x) for x in commandline]
|
| + print(' '.join(quoted), file=sys.stderr)
|
| +
|
|
|
| class StddevException(Exception):
|
| pass
|
| @@ -111,7 +116,26 @@ class SKPBench:
|
|
|
| @classmethod
|
| def print_header(cls):
|
| - subprocess.call(cls.ARGV + ['--duration', '0'])
|
| + commandline = cls.ARGV + ['--duration', '0']
|
| + dump_commandline_if_verbose(commandline)
|
| + subprocess.call(commandline)
|
| +
|
| + @classmethod
|
| + def run_warmup(cls, warmup_time):
|
| + if not warmup_time:
|
| + return
|
| + print('running %i second warmup...' % warmup_time)
|
| + commandline = cls.ARGV + ['--duration', str(warmup_time * 1000),
|
| + '--config', 'gpu',
|
| + '--skp', 'warmup']
|
| + dump_commandline_if_verbose(commandline)
|
| + output = subprocess.check_output(commandline).decode('utf-8')
|
| + # validate the warmup run output.
|
| + for line in output.split('\n'):
|
| + match = BenchResult.match(line.rstrip())
|
| + if match and match.bench == 'warmup':
|
| + return
|
| + raise Exception('Invalid warmup output:\n%s' % output)
|
|
|
| def __init__(self, skp, config, max_stddev, best_result=None):
|
| self.skp = skp
|
| @@ -143,9 +167,7 @@ class SKPBench:
|
| pngfile = _path.join(FLAGS.write_path, self.config,
|
| _path.basename(self.skp) + '.png')
|
| commandline.extend(['--png', pngfile])
|
| - if (FLAGS.verbosity >= 4):
|
| - quoted = ['\'%s\'' % re.sub(r'([\\\'])', r'\\\1', x) for x in commandline]
|
| - print(' '.join(quoted), file=sys.stderr)
|
| + dump_commandline_if_verbose(commandline)
|
| self._proc = subprocess.Popen(commandline, stdout=subprocess.PIPE)
|
| self._monitor = SubprocessMonitor(self._queue, self._proc)
|
| self._monitor.start()
|
| @@ -233,13 +255,12 @@ def run_benchmarks(configs, skps, hardware):
|
| if FLAGS.verbosity >= 5:
|
| hardware.print_debug_diagnostics()
|
| skpbench.terminate()
|
| - naptime = max(hardware.kick_in_time, exception.sleeptime)
|
| if FLAGS.verbosity >= 1:
|
| print("%s; taking a %i second nap..." %
|
| - (exception.message, naptime), file=sys.stderr)
|
| + (exception.message, exception.sleeptime), file=sys.stderr)
|
| benches.appendleft(benchargs) # retry the same bench next time.
|
| - hardware.sleep(naptime - hardware.kick_in_time)
|
| - time.sleep(hardware.kick_in_time)
|
| + hardware.sleep(exception.sleeptime)
|
| + SKPBench.run_warmup(hardware.warmup_time)
|
|
|
|
|
| def main():
|
| @@ -263,10 +284,7 @@ def main():
|
| hardware = Hardware()
|
|
|
| with hardware:
|
| - if hardware.kick_in_time:
|
| - print("sleeping %i seconds to allow hardware settings to kick in..." %
|
| - hardware.kick_in_time, file=sys.stderr)
|
| - time.sleep(hardware.kick_in_time)
|
| + SKPBench.run_warmup(hardware.warmup_time)
|
| run_benchmarks(configs, skps, hardware)
|
|
|
|
|
|
|