Skip to content

Commit

Permalink
Merge pull request #25 in G/mx from ~ALEKSANDAR.PROKOPEC_ORACLE.COM/m…
Browse files Browse the repository at this point in the history
…x:topic/show-version-string to master

* commit '8c96123b4de71f440c0b42b5f798513a3f0803c9':
  Add before hook, and show version string when running JVM benchmarks.
  • Loading branch information
axel22 committed Apr 13, 2016
2 parents b557632 + 8c96123 commit fe9fb14
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions mx_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ def runArgs(self, bmSuiteArgs):
"""
raise NotImplementedError()

def before(self, bmSuiteArgs):
"""Called exactly once before any benchmark invocations begin.
Useful for outputting information such as platform version, OS, etc.
Arguments: see `run`.
"""
pass

def run(self, benchmarks, bmSuiteArgs):
"""Runs the specified benchmarks with the given arguments.
Expand Down Expand Up @@ -307,11 +316,15 @@ def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
"""
raise NotImplementedError()

def before(self, bmSuiteArgs):
mx.log("Running on JVM with -version:")
mx.get_jdk().run_java(["-version"], nonZeroIsFatal=False)

def runAndReturnStdOut(self, benchmarks, bmSuiteArgs):
jdk = mx.get_jdk()
out = mx.TeeOutputCapture(mx.OutputCapture())
args = self.createCommandLineArgs(benchmarks, bmSuiteArgs)
mx.logv("Running JVM with args: {0}.".format(args))
mx.log("Running JVM with args: {0}.".format(args))
exitCode = jdk.run_java(args, out=out, err=out, nonZeroIsFatal=False)
return exitCode, out.underlying.data

Expand Down Expand Up @@ -455,14 +468,14 @@ def getSuiteAndBenchNames(self, args):
if not suite:
mx.abort("Cannot find benchmark suite '{0}'.".format(suitename))
if benchspec is "*":
return [(suite, [b]) for b in suite.benchmarks()]
return (suite, [[b] for b in suite.benchmarks()])
elif benchspec is "":
return [(suite, None)]
return (suite, [None])
elif not benchspec in suite.benchmarks():
mx.abort("Cannot find benchmark '{0}' in suite '{1}'.".format(
benchspec, suitename))
else:
return [(suite, [benchspec])]
return (suite, [[benchspec]])

def execute(self, suite, benchnames, mxBenchmarkArgs, bmSuiteArgs):
def postProcess(results):
Expand Down Expand Up @@ -492,10 +505,12 @@ def benchmark(self, mxBenchmarkArgs, bmSuiteArgs):

self.checkEnvironmentVars()

suiteBenchPairs = self.getSuiteAndBenchNames(mxBenchmarkArgs)
suite, benchNamesList = self.getSuiteAndBenchNames(mxBenchmarkArgs)

results = []
for suite, benchnames in suiteBenchPairs:

suite.before(bmSuiteArgs)
for benchnames in benchNamesList:
suite.validateEnvironment()
results.extend(
self.execute(suite, benchnames, mxBenchmarkArgs, bmSuiteArgs))
Expand Down

0 comments on commit fe9fb14

Please sign in to comment.