aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpbench
diff options
context:
space:
mode:
authorGravatar csmartdalton <csmartdalton@google.com>2016-11-10 10:36:28 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-10 16:08:12 +0000
commit49df7703180d791f59527a1ffd63eec0484284ed (patch)
treebec077f3ce5498028edca7ea84663dfc81259b75 /tools/skpbench
parentca85fc3159e9735b8e589bbc5b736a34affb12b5 (diff)
skpbench: add "resultsfile" option
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4654 Change-Id: I1a26eddb40de1398cad5348d3fe0ba397a87dbb0 Reviewed-on: https://skia-review.googlesource.com/4654 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'tools/skpbench')
-rw-r--r--tools/skpbench/_benchresult.py6
-rwxr-xr-xtools/skpbench/skpbench.py28
2 files changed, 22 insertions, 12 deletions
diff --git a/tools/skpbench/_benchresult.py b/tools/skpbench/_benchresult.py
index 666878bdc9..28d3aeaf4b 100644
--- a/tools/skpbench/_benchresult.py
+++ b/tools/skpbench/_benchresult.py
@@ -56,9 +56,9 @@ class BenchResult:
def get_string(self, name):
return self._match.group(name)
- def print_values(self, config_suffix=None, outfile=sys.stdout):
+ def format(self, config_suffix=None):
if not config_suffix or config_suffix == '':
- print(self._match.group(0), file=outfile)
+ return self._match.group(0)
else:
values = list()
for name in ['accum', 'median', 'max', 'min', 'stddev',
@@ -69,4 +69,4 @@ class BenchResult:
bench_pad = self.get_string('bench_pad')
values.append(bench_pad[min(len(config_suffix), len(bench_pad) - 1):])
values.append(self.get_string('bench'))
- print(''.join(values), file=outfile)
+ return ''.join(values)
diff --git a/tools/skpbench/skpbench.py b/tools/skpbench/skpbench.py
index 42263f073b..a21312365f 100755
--- a/tools/skpbench/skpbench.py
+++ b/tools/skpbench/skpbench.py
@@ -56,6 +56,8 @@ __argparse.add_argument('--fps',
action='store_true', help="use fps instead of ms")
__argparse.add_argument('-c', '--config',
default='gpu', help="comma- or space-separated list of GPU configs")
+__argparse.add_argument('-a', '--resultsfile',
+ help="optional file to append results into")
__argparse.add_argument('skps',
nargs='+',
help=".skp files or directories to expand for .skp files")
@@ -113,10 +115,11 @@ class SKPBench:
ARGV[:0] = ['adb', '-s', FLAGS.device_serial, 'shell']
@classmethod
- def print_header(cls):
+ def get_header(cls, outfile=sys.stdout):
commandline = cls.ARGV + ['--duration', '0']
dump_commandline_if_verbose(commandline)
- subprocess.call(commandline)
+ out = subprocess.check_output(commandline, stderr=subprocess.STDOUT)
+ return out.rstrip()
@classmethod
def run_warmup(cls, warmup_time):
@@ -210,7 +213,6 @@ class SKPBench:
"(%s%% instead of %s%%)." %
(result.config, result.bench, self.best_result.stddev,
result.stddev), file=sys.stderr)
- sys.stdout.flush()
if self.max_stddev and self.best_result.stddev > self.max_stddev:
raise StddevException()
@@ -221,10 +223,15 @@ class SKPBench:
self._proc.wait()
self._proc = None
+def emit_result(line, resultsfile=None):
+ print(line)
+ sys.stdout.flush()
+ if resultsfile:
+ print(line, file=resultsfile)
+ resultsfile.flush()
-def run_benchmarks(configs, skps, hardware):
- SKPBench.print_header()
-
+def run_benchmarks(configs, skps, hardware, resultsfile=None):
+ emit_result(SKPBench.get_header(), resultsfile)
benches = collections.deque([(skp, config, FLAGS.max_stddev)
for skp in skps
for config in configs])
@@ -234,7 +241,7 @@ def run_benchmarks(configs, skps, hardware):
try:
skpbench.execute(hardware)
if skpbench.best_result:
- skpbench.best_result.print_values(config_suffix=FLAGS.suffix)
+ emit_result(skpbench.best_result.format(FLAGS.suffix), resultsfile)
else:
print("WARNING: no result for %s with config %s" %
(skpbench.skp, skpbench.config), file=sys.stderr)
@@ -264,7 +271,6 @@ def run_benchmarks(configs, skps, hardware):
hardware.print_debug_diagnostics()
SKPBench.run_warmup(hardware.warmup_time)
-
def main():
# Delimiter is ',' or ' ', skip if nested inside parens (e.g. gpu(a=b,c=d)).
DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
@@ -290,7 +296,11 @@ def main():
with hardware:
SKPBench.run_warmup(hardware.warmup_time)
- run_benchmarks(configs, skps, hardware)
+ if FLAGS.resultsfile:
+ with open(FLAGS.resultsfile, mode='a+') as resultsfile:
+ run_benchmarks(configs, skps, hardware, resultsfile=resultsfile)
+ else:
+ run_benchmarks(configs, skps, hardware)
if __name__ == '__main__':