Make JSTests ready for Android measurements.

This adds a common perf configuration for JSTests including
Classes, Collections, Iterators and Strings. This allows
the android test runner to handle subdirectories correctly
and to share the base.js resource in the parent directory.

The new json config has added resources configs for the
Android runner.

The perf runner's relative paths on the device are fixed as
well. Resources are only pushed on the configuration node
where they are specified. They are pushed to a dir on the
device that follows the same directory structure as on the
host. The binary is executed in the benchmark folder on the
device like on the host to allow relative path file
loading.

BUG=chromium:374740
LOG=n
TEST=python -m unittest run_perf_test
TBR=ulan@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/779923002

Cr-Commit-Position: refs/heads/master@{#25655}
This commit is contained in:
machenbach 2014-12-04 02:37:36 -08:00 committed by Commit bot
parent ccf68a7b92
commit 1364ea7c77
2 changed files with 89 additions and 9 deletions

View File

@ -0,0 +1,69 @@
{
"name": "JSTests",
"run_count": 5,
"run_count_android_arm": 3,
"run_count_android_arm64": 3,
"units": "score",
"total": true,
"resources": ["base.js"],
"tests": [
{
"name": "Classes",
"path": ["Classes"],
"main": "run.js",
"resources": ["super.js"],
"flags": ["--harmony-classes"],
"results_regexp": "^%s\\-Classes\\(Score\\): (.+)$",
"tests": [
{"name": "Super"}
]
},
{
"name": "Collections",
"path": ["Collections"],
"main": "run.js",
"resources": [
"common.js",
"map.js",
"run.js",
"set.js",
"weakmap.js",
"weakset.js"
],
"results_regexp": "^%s\\-Collections\\(Score\\): (.+)$",
"tests": [
{"name": "Map-Smi"},
{"name": "Map-String"},
{"name": "Map-Object"},
{"name": "Map-Iteration"},
{"name": "Set-Smi"},
{"name": "Set-String"},
{"name": "Set-Object"},
{"name": "Set-Iteration"},
{"name": "WeakMap"},
{"name": "WeakSet"}
]
},
{
"name": "Iterators",
"path": ["Iterators"],
"main": "run.js",
"resources": ["forof.js"],
"results_regexp": "^%s\\-Iterators\\(Score\\): (.+)$",
"tests": [
{"name": "ForOf"}
]
},
{
"name": "Strings",
"path": ["Strings"],
"main": "run.js",
"resources": ["harmony-string.js"],
"flags": ["--harmony-strings"],
"results_regexp": "^%s\\-Strings\\(Score\\): (.+)$",
"tests": [
{"name": "StringFunctions"}
]
}
]
}

View File

@ -219,7 +219,9 @@ class Graph(Node):
self.graphs = parent.graphs[:] + [suite["name"]]
self.flags = parent.flags[:] + suite.get("flags", [])
self.test_flags = parent.test_flags[:] + suite.get("test_flags", [])
self.resources = parent.resources[:] + suite.get("resources", [])
# Values independent of parent node.
self.resources = suite.get("resources", [])
# Descrete values (with parent defaults).
self.binary = suite.get("binary", parent.binary)
@ -519,9 +521,10 @@ class AndroidPlatform(Platform): # pragma: no cover
cwd=AndroidPlatform.DEVICE_DIR,
)
def _PushFile(self, host_dir, file_name):
def _PushFile(self, host_dir, file_name, target_rel="."):
file_on_host = os.path.join(host_dir, file_name)
file_on_device = AndroidPlatform.DEVICE_DIR + file_name
file_on_device = os.path.join(
AndroidPlatform.DEVICE_DIR, target_rel, file_name)
# Only push files not yet pushed in one execution.
if file_on_host in self.pushed:
@ -535,26 +538,34 @@ class AndroidPlatform(Platform): # pragma: no cover
def PreTests(self, node, path):
suite_dir = os.path.abspath(os.path.dirname(path))
if node.path:
bench_dir = os.path.join(suite_dir,
os.path.normpath(os.path.join(*node.path)))
bench_rel = os.path.normpath(os.path.join(*node.path))
bench_abs = os.path.join(suite_dir, bench_rel)
else:
bench_dir = suite_dir
bench_rel = "."
bench_abs = suite_dir
self._PushFile(self.shell_dir, node.binary)
if isinstance(node, Runnable):
self._PushFile(bench_dir, node.main)
self._PushFile(bench_abs, node.main, bench_rel)
for resource in node.resources:
self._PushFile(bench_dir, resource)
self._PushFile(bench_abs, resource, bench_rel)
def Run(self, runnable, count):
cache = cache_control.CacheControl(self.device)
cache.DropRamCaches()
binary_on_device = AndroidPlatform.DEVICE_DIR + runnable.binary
cmd = [binary_on_device] + runnable.GetCommandFlags()
# Relative path to benchmark directory.
if runnable.path:
bench_rel = os.path.normpath(os.path.join(*runnable.path))
else:
bench_rel = "."
try:
output = self.device.RunShellCommand(
cmd,
cwd=AndroidPlatform.DEVICE_DIR,
cwd=os.path.join(AndroidPlatform.DEVICE_DIR, bench_rel),
timeout=runnable.timeout,
retries=0,
)