Mercurial > hg > truffle
comparison mx/mx_graal.py @ 15021:9dcd5407a603
added support for overriding/complementing JMH arguments in jmh command with a JSON string
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 08 Apr 2014 16:04:59 +0200 |
parents | a588d99d4be1 |
children | dfcb1a5a7b5a |
comparison
equal
deleted
inserted
replaced
15020:22390f39dfb1 | 15021:9dcd5407a603 |
---|---|
1347 | 1347 |
1348 def jmh(args): | 1348 def jmh(args): |
1349 """run the JMH_BENCHMARKS""" | 1349 """run the JMH_BENCHMARKS""" |
1350 | 1350 |
1351 # TODO: add option for `mvn clean package' | 1351 # TODO: add option for `mvn clean package' |
1352 # TODO: add options to pass through arguments directly to JMH | 1352 |
1353 | 1353 vmArgs, benchmarksAndJsons = _extract_VM_args(args) |
1354 vmArgs, benchmarks = _extract_VM_args(args) | 1354 |
1355 benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')] | |
1356 jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')] | |
1357 | |
1358 jmhArgs = { | |
1359 '-f' : '1', | |
1360 '-i' : '10', | |
1361 '-wi' : '10'} | |
1362 | |
1363 # e.g. '{"-wi" : 20}' | |
1364 for j in jmhArgJsons: | |
1365 try: | |
1366 jmhArgs.update(json.loads(j)) | |
1367 except ValueError as e: | |
1368 mx.abort('error parsing JSON input: {}"\n{}'.format(j, e)) | |
1369 | |
1355 jmhPath = mx.get_env('JMH_BENCHMARKS', None) | 1370 jmhPath = mx.get_env('JMH_BENCHMARKS', None) |
1356 if not jmhPath or not exists(jmhPath): | 1371 if not jmhPath or not exists(jmhPath): |
1357 mx.abort("$JMH_BENCHMARKS not properly defined: " + str(jmhPath)) | 1372 mx.abort("$JMH_BENCHMARKS not properly defined: " + str(jmhPath)) |
1358 | 1373 |
1359 def _blackhole(x): | 1374 def _blackhole(x): |
1408 for suite in matchedSuites: | 1423 for suite in matchedSuites: |
1409 absoluteMicro = os.path.join(jmhPath, suite) | 1424 absoluteMicro = os.path.join(jmhPath, suite) |
1410 (pfx, exe, vm, forkedVmArgs, _) = _parseVmArgs(vmArgs) | 1425 (pfx, exe, vm, forkedVmArgs, _) = _parseVmArgs(vmArgs) |
1411 if pfx: | 1426 if pfx: |
1412 mx.warn("JMH ignores prefix: \"" + pfx + "\"") | 1427 mx.warn("JMH ignores prefix: \"" + pfx + "\"") |
1413 mx.run_java( | 1428 javaArgs = ['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"), |
1414 ['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"), | 1429 '--jvm', exe, |
1415 "-f", "1", | 1430 '--jvmArgs', ' '.join(["-" + vm] + forkedVmArgs)] |
1416 "-v", "EXTRA" if mx._opts.verbose else "NORMAL", | 1431 for k, v in jmhArgs.iteritems(): |
1417 "-i", "10", "-wi", "10", | 1432 javaArgs.append(k) |
1418 "--jvm", exe, | 1433 javaArgs.append(str(v)) |
1419 "--jvmArgs", " ".join(["-" + vm] + forkedVmArgs)] + regex, | 1434 mx.run_java(javaArgs + regex, addDefaultArgs=False, cwd=jmhPath) |
1420 addDefaultArgs=False, | |
1421 cwd=jmhPath) | |
1422 | 1435 |
1423 | 1436 |
1424 def specjvm2008(args): | 1437 def specjvm2008(args): |
1425 """run one or more SPECjvm2008 benchmarks""" | 1438 """run one or more SPECjvm2008 benchmarks""" |
1426 | 1439 |
1759 'generateZshCompletion' : [generateZshCompletion, ''], | 1772 'generateZshCompletion' : [generateZshCompletion, ''], |
1760 'hsdis': [hsdis, '[att]'], | 1773 'hsdis': [hsdis, '[att]'], |
1761 'hcfdis': [hcfdis, ''], | 1774 'hcfdis': [hcfdis, ''], |
1762 'igv' : [igv, ''], | 1775 'igv' : [igv, ''], |
1763 'jdkhome': [print_jdkhome, ''], | 1776 'jdkhome': [print_jdkhome, ''], |
1764 'jmh': [jmh, '[VM options] [filters...]'], | 1777 'jmh': [jmh, '[VM options] [filters|JMH-args-as-json...]'], |
1765 'dacapo': [dacapo, '[VM options] benchmarks...|"all" [DaCapo options]'], | 1778 'dacapo': [dacapo, '[VM options] benchmarks...|"all" [DaCapo options]'], |
1766 'scaladacapo': [scaladacapo, '[VM options] benchmarks...|"all" [Scala DaCapo options]'], | 1779 'scaladacapo': [scaladacapo, '[VM options] benchmarks...|"all" [Scala DaCapo options]'], |
1767 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], | 1780 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], |
1768 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], | 1781 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], |
1769 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], | 1782 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], |