[test] Add an option to the perf runner to support running with the internal profiler.
authorgdeepti <gdeepti@google.com>
Mon, 14 Sep 2015 23:14:20 +0000 (16:14 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 14 Sep 2015 23:14:33 +0000 (23:14 +0000)
Enhance the perf runner to run with the profiler and print the summary for each d8 run. This automates running the profiler with multiple benchmarks.

BUG=None
LOG=N
TBR=machenbach@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30720}

tools/run_perf.py

index 3133168..a747b92 100755 (executable)
@@ -102,6 +102,7 @@ import math
 import optparse
 import os
 import re
+import subprocess
 import sys
 
 from testrunner.local import commands
@@ -457,7 +458,10 @@ class RunnableConfig(GraphConfig):
 
   def GetCommand(self, shell_dir, extra_flags=None):
     # TODO(machenbach): This requires +.exe if run on windows.
+    extra_flags = extra_flags or []
     cmd = [os.path.join(shell_dir, self.binary)]
+    if self.binary != 'd8' and '--prof' in self.extra_flags:
+      print "Profiler supported only on a benchmark run with d8"
     return cmd + self.GetCommandFlags(extra_flags=extra_flags)
 
   def Run(self, runner, trybot):
@@ -640,6 +644,19 @@ class DesktopPlatform(Platform):
       print output.stderr
     if output.timed_out:
       print ">>> Test timed out after %ss." % runnable.timeout
+    if '--prof' in self.extra_flags:
+      if utils.GuessOS() == "linux":
+        tick_tools = os.path.abspath(os.path.join(shell_dir, "..", "..",
+                                                  "tools",
+                                                  "linux-tick-processor"))
+      elif utils.GuessOS() == "macos":
+        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."
+      prof_cmd = tick_tools + " --only-summary"
+      subprocess.check_call(prof_cmd, shell=True)
     return output.stdout