Mercurial > hg > truffle
changeset 15178:0c53453c4d5e
mx: improved jmh command to (a) look for JMH benchmarks in ../java-benchmarks, (b) omit building benchmarks if they are up to date and (c) offer better message with 'mx help jmh'
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 17 Apr 2014 01:36:49 +0200 |
parents | 66e3af78ea96 |
children | d74a0522ef1b |
files | .hgignore mx/mx_graal.py |
diffstat | 2 files changed, 57 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Thu Apr 17 00:44:32 2014 +0200 +++ b/.hgignore Thu Apr 17 01:36:49 2014 +0200 @@ -5,6 +5,7 @@ ^mx/netbeans-config.zip ^mx/netbeans-config-libs.zip ^mx/eclipse-launches +^mx/jmh ^mx/currentAnnotationProcessors ^mx/ecj.jar ^mx/includes
--- a/mx/mx_graal.py Thu Apr 17 00:44:32 2014 +0200 +++ b/mx/mx_graal.py Thu Apr 17 01:36:49 2014 +0200 @@ -1404,7 +1404,16 @@ f.write(json.dumps(results)) def jmh(args): - """run the JMH_BENCHMARKS""" + """run the JMH_BENCHMARKS + + The benchmarks are running with the default VM. + You can override this with an explicit option. + For example: + + mx jmh -server ... + + Will force the benchmarks to be run with the server VM. +""" # TODO: add option for `mvn clean package' @@ -1413,7 +1422,7 @@ benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')] jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')] - jmhArgs = {'-v' : 'EXTRA' if mx._opts.verbose else 'NORMAL'} + jmhArgs = {'-rff' : join(_graal_home, 'mx', 'jmh', 'jmh.out'), '-v' : 'EXTRA' if mx._opts.verbose else 'NORMAL'} # e.g. '{"-wi" : 20}' for j in jmhArgJsons: @@ -1427,18 +1436,54 @@ mx.abort('error parsing JSON input: {}"\n{}'.format(j, e)) jmhPath = mx.get_env('JMH_BENCHMARKS', None) - if not jmhPath or not exists(jmhPath): - mx.abort("$JMH_BENCHMARKS not properly defined: " + str(jmhPath)) + if not jmhPath: + probe = join(dirname(_graal_home), 'java-benchmarks') + if exists(probe): + jmhPath = probe + + if not jmhPath: + mx.abort("Please set the JMH_BENCHMARKS environment variable to point to the java-benchmarks workspace") + if not exists(jmhPath): + mx.abort("The directory denoted by the JMH_BENCHMARKS environment variable does not exist: " + jmhPath) + mx.log('Using benchmarks in ' + jmhPath) - def _blackhole(x): - mx.logv(x[:-1]) + timestamp = mx.TimeStampFile(join(_graal_home, 'mx', 'jmh', jmhPath.replace(os.sep, '_') + '.timestamp')) + buildJmh = False + jmhTree = [] + for root, dirnames, filenames in os.walk(jmhPath): + if root == jmhPath: + for n in ['.hg', '.metadata']: + if n in dirnames: + dirnames.remove(n) + jmhTree.append(os.path.relpath(root, jmhPath) + ':') + jmhTree = jmhTree + filenames + jmhTree.append('') + files = [join(root, f) for f in filenames] + if timestamp.isOlderThan(files): + buildJmh = True - env = os.environ.copy() - env['JAVA_HOME'] = _jdk(vmToCheck='graal') - env['MAVEN_OPTS'] = '-graal' - mx.log("Building benchmarks...") - mx.run(['mvn', 'package'], cwd=jmhPath, out=_blackhole, env=env) + if not buildJmh: + with open(timestamp.path) as fp: + oldJmhTree = fp.read().split('\n') + if oldJmhTree != jmhTree: + import difflib + diff = difflib.unified_diff(oldJmhTree, jmhTree) + mx.log("Need to rebuild JMH due to change in JMH directory tree indicated by this diff:") + mx.log('\n'.join(diff)) + buildJmh = True + + if buildJmh: + def _blackhole(x): + mx.logv(x[:-1]) + env = os.environ.copy() + env['JAVA_HOME'] = _jdk(vmToCheck='graal') + env['MAVEN_OPTS'] = '-graal' + mx.log("Building benchmarks...") + mx.run(['mvn', 'package'], cwd=jmhPath, out=_blackhole, env=env) + timestamp.touch() + with open(timestamp.path, 'w') as fp: + fp.write('\n'.join(jmhTree)) matchedSuites = set() numBench = [0]