Mercurial > hg > graal-compiler
comparison mx/mx_graal.py @ 13948:69928d77bc0a
mx jmh: avoid mx crash if JMH_BENCHMARKS is not defined at all and skip suites that do not contain the correct jar
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 13 Feb 2014 15:39:18 +0100 |
parents | ca0e1af320f6 |
children | f694daada5bf |
comparison
equal
deleted
inserted
replaced
13947:1ea1566100bf | 13948:69928d77bc0a |
---|---|
1270 # TODO: add option for `mvn clean package' | 1270 # TODO: add option for `mvn clean package' |
1271 # TODO: add options to pass through arguments directly to JMH | 1271 # TODO: add options to pass through arguments directly to JMH |
1272 | 1272 |
1273 vmArgs, benchmarks = _extract_VM_args(args) | 1273 vmArgs, benchmarks = _extract_VM_args(args) |
1274 jmhPath = mx.get_env('JMH_BENCHMARKS', None) | 1274 jmhPath = mx.get_env('JMH_BENCHMARKS', None) |
1275 if not exists(jmhPath): | 1275 if not jmhPath or not exists(jmhPath): |
1276 mx.abort("$JMH_BENCHMARKS not properly definied") | 1276 mx.abort("$JMH_BENCHMARKS not properly definied") |
1277 | 1277 |
1278 def _blackhole(x): | 1278 def _blackhole(x): |
1279 mx.logv(x[:-1]) | 1279 mx.logv(x[:-1]) |
1280 | 1280 mx.log("Building benchmarks...") |
1281 mx.run(['mvn', 'package'], cwd = jmhPath, out = _blackhole) | 1281 mx.run(['mvn', 'package'], cwd = jmhPath, out = _blackhole) |
1282 | 1282 |
1283 matchedSuites = set() | 1283 matchedSuites = set() |
1284 for micros in os.listdir(jmhPath): | 1284 for micros in os.listdir(jmhPath): |
1285 absoluteMicro = os.path.join(jmhPath, micros) | 1285 absoluteMicro = os.path.join(jmhPath, micros) |
1287 continue | 1287 continue |
1288 if not micros.startswith("micros-"): | 1288 if not micros.startswith("micros-"): |
1289 mx.logv('JMH: ignored ' + absoluteMicro + " because it doesn't start with 'micros-'") | 1289 mx.logv('JMH: ignored ' + absoluteMicro + " because it doesn't start with 'micros-'") |
1290 continue | 1290 continue |
1291 | 1291 |
1292 microJar = os.path.join(absoluteMicro, "target", "microbenchmarks.jar") | |
1293 if not exists(microJar): | |
1294 mx.logv('JMH: ignored ' + absoluteMicro + " because it doesn't contain the expected jar file ('" + microJar + "')") | |
1295 continue | |
1292 if benchmarks: | 1296 if benchmarks: |
1293 def _addBenchmark(x): | 1297 def _addBenchmark(x): |
1294 if x.startswith("Benchmark:"): | 1298 if x.startswith("Benchmark:"): |
1295 return | 1299 return |
1296 match = False | 1300 match = False |
1298 match = match or (b in x) | 1302 match = match or (b in x) |
1299 | 1303 |
1300 if match: | 1304 if match: |
1301 matchedSuites.add(micros) | 1305 matchedSuites.add(micros) |
1302 | 1306 |
1303 mx.run_java(['-jar', os.path.join(absoluteMicro, "target", "microbenchmarks.jar"), "-l"], cwd = jmhPath, out = _addBenchmark) | 1307 |
1308 mx.run_java(['-jar', microJar, "-l"], cwd = jmhPath, out = _addBenchmark) | |
1304 else: | 1309 else: |
1305 matchedSuites.add(micros) | 1310 matchedSuites.add(micros) |
1306 | 1311 |
1307 mx.logv("matchedSuites: " + str(matchedSuites)) | 1312 mx.logv("matchedSuites: " + str(matchedSuites)) |
1308 | 1313 |