Mercurial > hg > truffle
comparison mx/mx_graal.py @ 18891:9afee75cee46
mx: add microbench command to run JMH benchmarks
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 21 Jan 2015 14:49:13 +0100 |
parents | 31960077ea9d |
children | 926488f5d345 |
comparison
equal
deleted
inserted
replaced
18890:f5cee3a0496c | 18891:9afee75cee46 |
---|---|
1 # | 1 # |
2 # commands.py - the GraalVM specific commands | 2 # commands.py - the GraalVM specific commands |
3 # | 3 # |
4 # ---------------------------------------------------------------------------------------------------- | 4 # ---------------------------------------------------------------------------------------------------- |
5 # | 5 # |
6 # Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. | 6 # Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8 # | 8 # |
9 # This code is free software; you can redistribute it and/or modify it | 9 # This code is free software; you can redistribute it and/or modify it |
10 # under the terms of the GNU General Public License version 2 only, as | 10 # under the terms of the GNU General Public License version 2 only, as |
11 # published by the Free Software Foundation. | 11 # published by the Free Software Foundation. |
1334 def shortunittest(args): | 1334 def shortunittest(args): |
1335 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}""" | 1335 """alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}""" |
1336 | 1336 |
1337 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args | 1337 args = ['--whitelist', 'test/whitelist_shortunittest.txt'] + args |
1338 unittest(args) | 1338 unittest(args) |
1339 | |
1340 def microbench(args): | |
1341 """run JMH microbenchmark projects""" | |
1342 vmArgs, jmhArgs = _extract_VM_args(args, useDoubleDash=True) | |
1343 | |
1344 # look for -f in JMH arguments | |
1345 containsF = False | |
1346 forking = True | |
1347 for i in range(len(jmhArgs)): | |
1348 arg = jmhArgs[i] | |
1349 if arg.startswith('-f'): | |
1350 containsF = True | |
1351 if arg == '-f' and (i+1) < len(jmhArgs): | |
1352 arg += jmhArgs[i+1] | |
1353 try: | |
1354 if int(arg[2:]) == 0: | |
1355 forking = False | |
1356 except ValueError: | |
1357 pass | |
1358 | |
1359 # default to -f1 if not specified otherwise | |
1360 if not containsF: | |
1361 jmhArgs += ['-f1'] | |
1362 | |
1363 # find all projects with the JMH dependency | |
1364 jmhProjects = [] | |
1365 for p in mx.projects(): | |
1366 if 'JMH' in p.deps: | |
1367 jmhProjects.append(p.name) | |
1368 cp = mx.classpath(jmhProjects) | |
1369 | |
1370 # execute JMH runner | |
1371 (_, _, jvm, forkedVmArgs, _) = _parseVmArgs(vmArgs) | |
1372 args = ['-cp', cp] | |
1373 if not forking: | |
1374 args += forkedVmArgs | |
1375 args += ['org.openjdk.jmh.Main'] | |
1376 if forking: | |
1377 args += ['--jvmArgsPrepend', ' '.join(['-' + jvm] + forkedVmArgs)] | |
1378 vm(args + jmhArgs) | |
1339 | 1379 |
1340 def buildvms(args): | 1380 def buildvms(args): |
1341 """build one or more VMs in various configurations""" | 1381 """build one or more VMs in various configurations""" |
1342 | 1382 |
1343 vmsDefault = ','.join(_vmChoices.keys()) | 1383 vmsDefault = ','.join(_vmChoices.keys()) |
2396 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], | 2436 'specjvm2008': [specjvm2008, '[VM options] benchmarks...|"all" [SPECjvm2008 options]'], |
2397 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], | 2437 'specjbb2013': [specjbb2013, '[VM options] [-- [SPECjbb2013 options]]'], |
2398 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], | 2438 'specjbb2005': [specjbb2005, '[VM options] [-- [SPECjbb2005 options]]'], |
2399 'gate' : [gate, '[-options]'], | 2439 'gate' : [gate, '[-options]'], |
2400 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], | 2440 'bench' : [bench, '[-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], |
2441 'microbench' : [microbench, '[VM options] [-- [JMH options]]'], | |
2401 'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], | 2442 'unittest' : [unittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], |
2402 'makejmhdeps' : [makejmhdeps, ''], | 2443 'makejmhdeps' : [makejmhdeps, ''], |
2403 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], | 2444 'shortunittest' : [shortunittest, '[unittest options] [--] [VM options] [filters...]', _unittestHelpSuffix], |
2404 'jacocoreport' : [jacocoreport, '[output directory]'], | 2445 'jacocoreport' : [jacocoreport, '[output directory]'], |
2405 'site' : [site, '[-options]'], | 2446 'site' : [site, '[-options]'], |