Add adb support to skpbench
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2350003002 Review-Url: https://codereview.chromium.org/2350003002
This commit is contained in:
parent
613664b1bc
commit
0262b5c1a0
19
tools/skpbench/_adb.py
Normal file
19
tools/skpbench/_adb.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import subprocess
|
||||
|
||||
def shell(cmd, device_serial=None):
|
||||
if device_serial is None:
|
||||
subprocess.call(['adb', 'shell', cmd])
|
||||
else:
|
||||
subprocess.call(['adb', '-s', device_serial, 'shell', cmd])
|
||||
|
||||
def check(cmd, device_serial=None):
|
||||
if device_serial is None:
|
||||
out = subprocess.check_output(['adb', 'shell', cmd])
|
||||
else:
|
||||
out = subprocess.check_output(['adb', '-s', device_serial, 'shell', cmd])
|
||||
return out.rstrip()
|
33
tools/skpbench/_adb_path.py
Normal file
33
tools/skpbench/_adb_path.py
Normal file
@ -0,0 +1,33 @@
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import _adb
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
__ADB_DEVICE_SERIAL = None
|
||||
|
||||
def set_device_serial(device_serial):
|
||||
global __ADB_DEVICE_SERIAL
|
||||
__ADB_DEVICE_SERIAL = device_serial
|
||||
|
||||
def join(*pathnames):
|
||||
return '/'.join(pathnames)
|
||||
|
||||
def basename(pathname):
|
||||
return pathname.rsplit('/', maxsplit=1)[-1]
|
||||
|
||||
def find_skps(skps):
|
||||
escapedskps = [re.sub(r'([^a-zA-Z0-9_\*\?\[\!\]])', r'\\\1', x) # Keep globs.
|
||||
for x in skps]
|
||||
pathnames = _adb.check('''
|
||||
for PATHNAME in %s; do
|
||||
if [ -d "$PATHNAME" ]; then
|
||||
ls "$PATHNAME"/*.skp
|
||||
else
|
||||
echo "$PATHNAME"
|
||||
fi
|
||||
done''' % ' '.join(escapedskps), device_serial=__ADB_DEVICE_SERIAL)
|
||||
return re.split('[\r\n]+', pathnames)
|
22
tools/skpbench/_os_path.py
Normal file
22
tools/skpbench/_os_path.py
Normal file
@ -0,0 +1,22 @@
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from os import path
|
||||
import glob
|
||||
|
||||
def join(*pathnames):
|
||||
return path.join(*pathnames)
|
||||
|
||||
def basename(pathname):
|
||||
return pathname.basename(pathname)
|
||||
|
||||
def find_skps(skps):
|
||||
pathnames = list()
|
||||
for skp in skps:
|
||||
if (path.isdir(skp)):
|
||||
pathnames.extend(glob.iglob(path.join(skp, '*.skp')))
|
||||
else:
|
||||
pathnames.append(skp)
|
||||
return pathnames
|
@ -8,7 +8,6 @@
|
||||
from __future__ import print_function
|
||||
from _benchresult import BenchResult
|
||||
from argparse import ArgumentParser
|
||||
from os import path
|
||||
from queue import Queue
|
||||
from threading import Thread
|
||||
import collections
|
||||
@ -27,6 +26,10 @@ unacceptable stddev.
|
||||
|
||||
""")
|
||||
|
||||
__argparse.add_argument('--adb',
|
||||
action='store_true', help='execute skpbench over adb')
|
||||
__argparse.add_argument('-s', '--device-serial',
|
||||
help='if using adb, id of the specific device to target')
|
||||
__argparse.add_argument('-p', '--path',
|
||||
help='directory to execute ./skpbench from')
|
||||
__argparse.add_argument('-m', '--max-stddev',
|
||||
@ -51,6 +54,11 @@ __argparse.add_argument('skps',
|
||||
help='.skp files or directories to expand for .skp files')
|
||||
|
||||
FLAGS = __argparse.parse_args()
|
||||
if FLAGS.adb:
|
||||
import _adb_path as _path
|
||||
_path.set_device_serial(FLAGS.device_serial)
|
||||
else:
|
||||
import _os_path as _path
|
||||
|
||||
|
||||
class StddevException(Exception):
|
||||
@ -65,14 +73,19 @@ class Message:
|
||||
|
||||
class SKPBench(Thread):
|
||||
ARGV = ['skpbench', '--verbosity', str(FLAGS.verbosity)]
|
||||
if FLAGS.path:
|
||||
ARGV[0] = path.join(FLAGS.path, ARGV[0])
|
||||
if FLAGS.samples:
|
||||
ARGV.extend(['--samples', str(FLAGS.samples)])
|
||||
if FLAGS.sample_ms:
|
||||
ARGV.extend(['--sampleMs', str(FLAGS.sample_ms)])
|
||||
if FLAGS.fps:
|
||||
ARGV.extend(['--fps', 'true'])
|
||||
if FLAGS.path:
|
||||
ARGV[0] = _path.join(FLAGS.path, ARGV[0])
|
||||
if FLAGS.adb:
|
||||
if FLAGS.device_serial is None:
|
||||
ARGV = ['adb', 'shell'] + ARGV
|
||||
else:
|
||||
ARGV = ['adb', '-s', FLAGS.device_serial, 'shell'] + ARGV
|
||||
|
||||
@classmethod
|
||||
def print_header(cls):
|
||||
@ -124,8 +137,8 @@ class SKPBench(Thread):
|
||||
'--skp', self.skp,
|
||||
'--suppressHeader', 'true']
|
||||
if (FLAGS.write_path):
|
||||
pngfile = path.join(FLAGS.write_path, self.config,
|
||||
path.basename(self.skp) + '.png')
|
||||
pngfile = _path.join(FLAGS.write_path, self.config,
|
||||
_path.basename(self.skp) + '.png')
|
||||
commandline.extend(['--png', pngfile])
|
||||
if (FLAGS.verbosity >= 3):
|
||||
print(' '.join(commandline), file=sys.stderr)
|
||||
@ -142,13 +155,7 @@ def main():
|
||||
# Delimiter is "," or " ", skip if nested inside parens (e.g. gpu(a=b,c=d)).
|
||||
DELIMITER = r'[, ](?!(?:[^(]*\([^)]*\))*[^()]*\))'
|
||||
configs = re.split(DELIMITER, FLAGS.config)
|
||||
|
||||
skps = list()
|
||||
for skp in FLAGS.skps:
|
||||
if (path.isdir(skp)):
|
||||
skps.extend(glob.iglob(path.join(skp, '*.skp')))
|
||||
else:
|
||||
skps.append(skp)
|
||||
skps = _path.find_skps(FLAGS.skps)
|
||||
|
||||
benches = collections.deque([(skp, config, FLAGS.max_stddev)
|
||||
for skp in skps
|
||||
|
Loading…
Reference in New Issue
Block a user