aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpbench/skpbench.py
diff options
context:
space:
mode:
authorGravatar csmartdalton <csmartdalton@google.com>2016-10-11 18:28:54 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-11 18:28:54 -0700
commit5772eaa91d6a10d74959d7732513c5ab9c057e03 (patch)
treefe372c5cbf1da303e91b46f1dfb92751732cffbd /tools/skpbench/skpbench.py
parent768bdfca71391016c92239831d66427d0f3b151d (diff)
skpbench: add warmup run
Does actual work while waiting for hardware settings to kick in, rather than just sleeping. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2410373002 Review-Url: https://codereview.chromium.org/2410373002
Diffstat (limited to 'tools/skpbench/skpbench.py')
-rwxr-xr-xtools/skpbench/skpbench.py42
1 files changed, 30 insertions, 12 deletions
diff --git a/tools/skpbench/skpbench.py b/tools/skpbench/skpbench.py
index 932d8d0461..9598162693 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)