Commit 18d2c58c authored by machenbach's avatar machenbach Committed by Commit bot

[test] More robust perf runner with profiler option.

NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#30731}
parent 8d77f788
...@@ -121,6 +121,7 @@ SUPPORTED_ARCHS = ["arm", ...@@ -121,6 +121,7 @@ SUPPORTED_ARCHS = ["arm",
GENERIC_RESULTS_RE = re.compile(r"^RESULT ([^:]+): ([^=]+)= ([^ ]+) ([^ ]*)$") GENERIC_RESULTS_RE = re.compile(r"^RESULT ([^:]+): ([^=]+)= ([^ ]+) ([^ ]*)$")
RESULT_STDDEV_RE = re.compile(r"^\{([^\}]+)\}$") RESULT_STDDEV_RE = re.compile(r"^\{([^\}]+)\}$")
RESULT_LIST_RE = re.compile(r"^\[([^\]]+)\]$") RESULT_LIST_RE = re.compile(r"^\[([^\]]+)\]$")
TOOLS_BASE = os.path.abspath(os.path.dirname(__file__))
def LoadAndroidBuildTools(path): # pragma: no cover def LoadAndroidBuildTools(path): # pragma: no cover
...@@ -460,7 +461,7 @@ class RunnableConfig(GraphConfig): ...@@ -460,7 +461,7 @@ class RunnableConfig(GraphConfig):
# TODO(machenbach): This requires +.exe if run on windows. # TODO(machenbach): This requires +.exe if run on windows.
extra_flags = extra_flags or [] extra_flags = extra_flags or []
cmd = [os.path.join(shell_dir, self.binary)] cmd = [os.path.join(shell_dir, self.binary)]
if self.binary != 'd8' and '--prof' in self.extra_flags: if self.binary != 'd8' and '--prof' in extra_flags:
print "Profiler supported only on a benchmark run with d8" print "Profiler supported only on a benchmark run with d8"
return cmd + self.GetCommandFlags(extra_flags=extra_flags) return cmd + self.GetCommandFlags(extra_flags=extra_flags)
...@@ -645,18 +646,12 @@ class DesktopPlatform(Platform): ...@@ -645,18 +646,12 @@ class DesktopPlatform(Platform):
if output.timed_out: if output.timed_out:
print ">>> Test timed out after %ss." % runnable.timeout print ">>> Test timed out after %ss." % runnable.timeout
if '--prof' in self.extra_flags: if '--prof' in self.extra_flags:
if utils.GuessOS() == "linux": os_prefix = {"linux": "linux", "macos": "mac"}.get(utils.GuessOS())
tick_tools = os.path.abspath(os.path.join(shell_dir, "..", "..", if os_prefix:
"tools", tick_tools = os.path.join(TOOLS_BASE, "%s-tick-processor" % os_prefix)
"linux-tick-processor")) subprocess.check_call(tick_tools + " --only-summary", shell=True)
elif utils.GuessOS() == "macos": else: # pragma: no cover
tick_tools = os.path.abspath(os.path.join(shell_dir, "..", "..",
"tools",
"mac-tick-processor"))
else:
print "Profiler option currently supported on Linux and Mac OS." print "Profiler option currently supported on Linux and Mac OS."
prof_cmd = tick_tools + " --only-summary"
subprocess.check_call(prof_cmd, shell=True)
return output.stdout return output.stdout
......
...@@ -10,7 +10,9 @@ from mock import DEFAULT ...@@ -10,7 +10,9 @@ from mock import DEFAULT
from mock import MagicMock from mock import MagicMock
import os import os
from os import path, sys from os import path, sys
import platform
import shutil import shutil
import subprocess
import tempfile import tempfile
import unittest import unittest
...@@ -129,6 +131,9 @@ class PerfTest(unittest.TestCase): ...@@ -129,6 +131,9 @@ class PerfTest(unittest.TestCase):
self.assertEquals(dirs.pop(), args[0]) self.assertEquals(dirs.pop(), args[0])
os.chdir = MagicMock(side_effect=chdir) os.chdir = MagicMock(side_effect=chdir)
subprocess.check_call = MagicMock()
platform.system = MagicMock(return_value='Linux')
def _CallMain(self, *args): def _CallMain(self, *args):
self._test_output = path.join(TEST_WORKSPACE, "results.json") self._test_output = path.join(TEST_WORKSPACE, "results.json")
all_args=[ all_args=[
...@@ -448,6 +453,19 @@ class PerfTest(unittest.TestCase): ...@@ -448,6 +453,19 @@ class PerfTest(unittest.TestCase):
(path.join("out-no-patch", "x64.release", "d7"), "--flag", "run.js"), (path.join("out-no-patch", "x64.release", "d7"), "--flag", "run.js"),
) )
def testWrongBinaryWithProf(self):
test_input = dict(V8_JSON)
self._WriteTestInput(test_input)
self._MockCommand(["."], ["x\nRichards: 1.234\nDeltaBlue: 10657567\ny\n"])
self.assertEquals(0, self._CallMain("--extra-flags=--prof"))
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["1.234"], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
])
self._VerifyErrors([])
self._VerifyMock(path.join("out", "x64.release", "d7"),
"--flag", "--prof", "run.js")
def testUnzip(self): def testUnzip(self):
def Gen(): def Gen():
for i in [1, 2, 3]: for i in [1, 2, 3]:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment