Mercurial > hg > truffle
comparison mx/commands.py @ 4282:063ea022532c
mx commands : improve bench command, fix in the outparser so that no empty 'line' is retruned if there was no match, fix bootstrap's regex
author | Gilles Duboscq <gilles.m.duboscq@gmail.com> |
---|---|
date | Fri, 13 Jan 2012 16:11:18 +0100 |
parents | f8f262212aa4 |
children | 2bc254976621 |
comparison
equal
deleted
inserted
replaced
4276:f8f262212aa4 | 4282:063ea022532c |
---|---|
29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, StringIO | 29 import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, StringIO |
30 from os.path import join, exists, dirname, basename | 30 from os.path import join, exists, dirname, basename |
31 from argparse import ArgumentParser, REMAINDER | 31 from argparse import ArgumentParser, REMAINDER |
32 import mx | 32 import mx |
33 import sanitycheck | 33 import sanitycheck |
34 import json | |
34 | 35 |
35 _graal_home = dirname(dirname(__file__)) | 36 _graal_home = dirname(dirname(__file__)) |
36 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) | 37 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) |
37 _vmbuild = 'product' | 38 _vmbuild = 'product' |
38 | 39 |
505 total.abort(str(e)) | 506 total.abort(str(e)) |
506 | 507 |
507 total.stop() | 508 total.stop() |
508 | 509 |
509 def bench(args): | 510 def bench(args): |
511 """run benchmarks and parse their ouput for results | |
512 | |
513 Results are JSON formated : {group : {benchmark : score}}.""" | |
514 resultFile = None | |
515 if '-resultfile' in args: | |
516 index = args.index('-resultfile') | |
517 if index + 1 < len(args): | |
518 resultFile = args[index + 1] | |
519 del args[index] | |
520 del args[index] | |
521 else: | |
522 mx.abort('-resultfile must be followed by a file name') | |
523 vm = 'graal' | |
524 if '-vm' in args: | |
525 index = args.index('-vm') | |
526 if index + 1 < len(args): | |
527 vm = args[index + 1] | |
528 del args[index] | |
529 del args[index] | |
530 else: | |
531 mx.abort('-vm must be followed by a vm name (graal, server, client..)') | |
532 if len(args) is 0: | |
533 args += ['all'] | |
534 | |
510 results = {} | 535 results = {} |
536 benchmarks = [] | |
511 #DaCapo | 537 #DaCapo |
512 benchmarks = sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) | 538 if ('dacapo' in args or 'all' in args): |
539 benchmarks += sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) | |
513 #Bootstrap | 540 #Bootstrap |
514 benchmarks += sanitycheck.getBootstraps() | 541 if ('bootstrap' in args or 'all' in args): |
542 benchmarks += sanitycheck.getBootstraps() | |
515 #SPECjvm2008 | 543 #SPECjvm2008 |
516 benchmarks += [sanitycheck.getSPECjvm2008(True, 60, 120)] | 544 if ('specjvm2008' in args or 'all' in args): |
545 benchmarks += [sanitycheck.getSPECjvm2008(True, 60, 120)] | |
517 | 546 |
518 for test in benchmarks: | 547 for test in benchmarks: |
519 if not results.has_key(test.group): | 548 if not results.has_key(test.group): |
520 results[test.group] = {} | 549 results[test.group] = {} |
521 results[test.group].update(test.bench('-graal')) | 550 results[test.group].update(test.bench('-' + vm)) |
522 print results | 551 mx.log(json.dumps(results)) |
552 if resultFile: | |
553 with open(resultFile, 'w') as f: | |
554 f.write(json.dumps(results)) | |
523 | 555 |
524 def specjvm2008(args): | 556 def specjvm2008(args): |
525 sanitycheck.getSPECjvm2008().bench('-graal') | 557 sanitycheck.getSPECjvm2008().bench('-graal') |
526 | 558 |
527 def mx_init(): | 559 def mx_init(): |
532 'copyrightcheck': [copyrightcheck, ''], | 564 'copyrightcheck': [copyrightcheck, ''], |
533 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'], | 565 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'], |
534 'specjvm2008': [specjvm2008, ''], | 566 'specjvm2008': [specjvm2008, ''], |
535 'example': [example, '[-v] example names...'], | 567 'example': [example, '[-v] example names...'], |
536 'gate' : [gate, ''], | 568 'gate' : [gate, ''], |
537 'bench' : [bench, ''], | 569 'bench' : [bench, '[-vm vm] [-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], |
538 'unittest' : [unittest, '[filters...]'], | 570 'unittest' : [unittest, '[filters...]'], |
539 'vm': [vm, '[-options] class [args...]'] | 571 'vm': [vm, '[-options] class [args...]'] |
540 } | 572 } |
541 | 573 |
542 if (_vmSourcesAvailable): | 574 if (_vmSourcesAvailable): |