Revision: 23329
Author:   [email protected]
Date:     Sun Aug 24 14:32:44 2014 UTC
Log:      Teach benchmark runner to understand generic traces.

BUG=406405
LOG=n
TEST=python -m unittest run_benchmarks_test
[email protected]

Review URL: https://codereview.chromium.org/502473002
https://code.google.com/p/v8/source/detail?r=23329

Modified:
 /branches/bleeding_edge/tools/run_benchmarks.py
 /branches/bleeding_edge/tools/unittests/run_benchmarks_test.py

=======================================
--- /branches/bleeding_edge/tools/run_benchmarks.py Wed Jul 16 09:54:34 2014 UTC +++ /branches/bleeding_edge/tools/run_benchmarks.py Sun Aug 24 14:32:44 2014 UTC
@@ -113,6 +113,8 @@
                    "x64",
                    "arm64"]

+GENERIC_RESULTS_RE = re.compile(
+    r"^Trace\(([^\)]+)\), Result\(([^\)]+)\), StdDev\(([^\)]+)\)$")

 class Results(object):
   """Place holder for result traces."""
@@ -249,7 +251,7 @@
   """
   @property
   def main(self):
-    return self._suite["main"]
+    return self._suite.get("main", "")

   def ChangeCWD(self, suite_path):
     """Changes the cwd to to path defined in the current graph.
@@ -289,6 +291,33 @@
     return self.GetResults()


+class RunnableGeneric(Runnable):
+ """Represents a runnable benchmark suite definition with generic traces."""
+  def __init__(self, suite, parent, arch):
+    super(RunnableGeneric, self).__init__(suite, parent, arch)
+
+  def Run(self, runner):
+    """Iterates over several runs and handles the output."""
+    traces = {}
+    for stdout in runner():
+      for line in stdout.strip().splitlines():
+        match = GENERIC_RESULTS_RE.match(line)
+        if match:
+          trace = match.group(1)
+          result = match.group(2)
+          stddev = match.group(3)
+          trace_result = traces.setdefault(trace, Results([{
+            "graphs": self.graphs + [trace],
+            "units": self.units,
+            "results": [],
+            "stddev": "",
+          }], []))
+          trace_result.traces[0]["results"].append(result)
+          trace_result.traces[0]["stddev"] = stddev
+
+    return reduce(lambda r, t: r + t, traces.itervalues(), Results())
+
+
 def MakeGraph(suite, arch, parent):
   """Factory method for making graph objects."""
   if isinstance(parent, Runnable):
@@ -302,6 +331,10 @@
     else:
       # This graph has no subbenchmarks, it's a leaf.
       return RunnableTrace(suite, parent, arch)
+  elif suite.get("generic"):
+ # This is a generic suite definition. It is either a runnable executable
+    # or has a main js file.
+    return RunnableGeneric(suite, parent, arch)
   elif suite.get("benchmarks"):
     # This is neither a leaf nor a runnable.
     return Graph(suite, parent, arch)
=======================================
--- /branches/bleeding_edge/tools/unittests/run_benchmarks_test.py Wed Jul 16 08:53:46 2014 UTC +++ /branches/bleeding_edge/tools/unittests/run_benchmarks_test.py Sun Aug 24 14:32:44 2014 UTC
@@ -67,6 +67,15 @@
      "main": "run.js"},
   ]
 }
+
+V8_GENERIC_JSON = {
+  "path": ["."],
+  "binary": "cc",
+  "flags": ["--flag"],
+  "generic": True,
+  "run_count": 1,
+  "units": "ms",
+}

 Output = namedtuple("Output", "stdout, stderr")

@@ -295,3 +304,17 @@
     self._VerifyErrors(
["Regexp \"^Richards: (.+)$\" didn't match for benchmark Richards."]) self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")
+
+  def testOneRunGeneric(self):
+    test_input = dict(V8_GENERIC_JSON)
+    self._WriteTestInput(test_input)
+    self._MockCommand(["."], [
+      "Trace(Test1), Result(1.234), StdDev(0.23)\n"
+      "Trace(Test2), Result(10657567), StdDev(106)\n"])
+    self.assertEquals(0, self._CallMain())
+    self._VerifyResults("test", "ms", [
+      {"name": "Test1", "results": ["1.234"], "stddev": "0.23"},
+      {"name": "Test2", "results": ["10657567"], "stddev": "106"},
+    ])
+    self._VerifyErrors([])
+    self._VerifyMock(path.join("out", "x64.release", "cc"), "--flag", "")

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to