Chromium Code Reviews| Index: tools/run_perf.py |
| diff --git a/tools/run_perf.py b/tools/run_perf.py |
| index 31331686fa0f0598b1de48ddc4f4b221e21f158e..717547a33856a7017f4d8fa98ddfd14ea3ad73fb 100755 |
| --- a/tools/run_perf.py |
| +++ b/tools/run_perf.py |
| @@ -102,6 +102,7 @@ import math |
| import optparse |
| import os |
| import re |
| +import subprocess |
| import sys |
| from testrunner.local import commands |
| @@ -455,9 +456,13 @@ class RunnableConfig(GraphConfig): |
| suffix = ["--"] + self.test_flags if self.test_flags else [] |
| return self.flags + (extra_flags or []) + [self.main] + suffix |
| - def GetCommand(self, shell_dir, extra_flags=None): |
| + def GetCommand(self, shell_dir, extra_flags=None, profiler_run=False): |
| # TODO(machenbach): This requires +.exe if run on windows. |
| cmd = [os.path.join(shell_dir, self.binary)] |
| + if self.binary == 'd8' and profiler_run: |
| + cmd = cmd + ["--prof"] |
| + else: |
| + print "Profiler supported only on a benchmark run with d8" |
| return cmd + self.GetCommandFlags(extra_flags=extra_flags) |
| def Run(self, runner, trybot): |
| @@ -583,10 +588,10 @@ class Platform(object): |
| else: |
| return DesktopPlatform(options) |
| - def _Run(self, runnable, count, no_patch=False): |
| + def _Run(self, runnable, count, no_patch=False, profiler_run=False): |
| raise NotImplementedError() # pragma: no cover |
| - def Run(self, runnable, count): |
| + def Run(self, runnable, count, profiler_run=False): |
| """Execute the benchmark's main file. |
| If options.shell_dir_no_patch is specified, the benchmark is run once with |
| @@ -598,9 +603,11 @@ class Platform(object): |
| latter will be None if options.shell_dir_no_patch was not |
| specified. |
| """ |
| - stdout = self._Run(runnable, count, no_patch=False) |
| + stdout = self._Run(runnable, count, no_patch=False, |
| + profiler_run=profiler_run) |
| if self.shell_dir_no_patch: |
| - return stdout, self._Run(runnable, count, no_patch=True) |
| + return stdout, self._Run(runnable, count, no_patch=True, |
| + profiler_run=profiler_run) |
| else: |
| return stdout, None |
| @@ -619,13 +626,14 @@ class DesktopPlatform(Platform): |
| if isinstance(node, RunnableConfig): |
| node.ChangeCWD(path) |
| - def _Run(self, runnable, count, no_patch=False): |
| + def _Run(self, runnable, count, no_patch=False, profiler_run=False): |
| suffix = ' - without patch' if no_patch else '' |
| shell_dir = self.shell_dir_no_patch if no_patch else self.shell_dir |
| title = ">>> %%s (#%d)%s:" % ((count + 1), suffix) |
| try: |
| output = commands.Execute( |
| - runnable.GetCommand(shell_dir, self.extra_flags), |
| + runnable.GetCommand(shell_dir, self.extra_flags, |
| + profiler_run=profiler_run), |
| timeout=runnable.timeout, |
| ) |
| except OSError as e: # pragma: no cover |
| @@ -640,6 +648,19 @@ class DesktopPlatform(Platform): |
| print output.stderr |
| if output.timed_out: |
| print ">>> Test timed out after %ss." % runnable.timeout |
| + if profiler_run: |
|
Michael Achenbach
2015/09/10 07:49:44
Suggestion: Could you maybe just use the existing
gdeepti1
2015/09/11 08:22:33
Currently passing in the --profiler flag to run_pe
Michael Achenbach
2015/09/11 09:13:02
Hmm - not sure if I understand. I don't wanna impl
gdeepti1
2015/09/11 20:05:57
Thanks for clarifying, simplified to use --extra-f
|
| + 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 |
| @@ -800,7 +821,11 @@ def Main(args): |
| parser.add_option("--outdir", help="Base directory with compile output", |
| default="out") |
| parser.add_option("--outdir-no-patch", |
| - help="Base directory with compile output without patch") |
| + help="Base directory with compile output without patch"), |
| + parser.add_option("--profiler", |
| + help="Run with the profiler and print the summary " |
| + "for each run", |
| + default=False, action="store_true") |
| (options, args) = parser.parse_args(args) |
| if len(args) == 0: # pragma: no cover |
| @@ -875,7 +900,7 @@ def Main(args): |
| for i in xrange(0, max(1, runnable.run_count)): |
| # TODO(machenbach): Allow timeout per arch like with run_count per |
| # arch. |
| - yield platform.Run(runnable, i) |
| + yield platform.Run(runnable, i, options.profiler) |
| # Let runnable iterate over all runs and handle output. |
| result, result_no_patch = runnable.Run( |