# HG changeset patch # User Gilles Duboscq # Date 1326467478 -3600 # Node ID 063ea022532cd16c719abc21aeac4a5d60e19a4c # Parent f8f262212aa40cb5bea50e5f96cdbc590257d030 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 diff -r f8f262212aa4 -r 063ea022532c mx/commands.py --- a/mx/commands.py Thu Jan 12 16:08:41 2012 +0100 +++ b/mx/commands.py Fri Jan 13 16:11:18 2012 +0100 @@ -31,6 +31,7 @@ from argparse import ArgumentParser, REMAINDER import mx import sanitycheck +import json _graal_home = dirname(dirname(__file__)) _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) @@ -507,19 +508,50 @@ total.stop() def bench(args): + """run benchmarks and parse their ouput for results + + Results are JSON formated : {group : {benchmark : score}}.""" + resultFile = None + if '-resultfile' in args: + index = args.index('-resultfile') + if index + 1 < len(args): + resultFile = args[index + 1] + del args[index] + del args[index] + else: + mx.abort('-resultfile must be followed by a file name') + vm = 'graal' + if '-vm' in args: + index = args.index('-vm') + if index + 1 < len(args): + vm = args[index + 1] + del args[index] + del args[index] + else: + mx.abort('-vm must be followed by a vm name (graal, server, client..)') + if len(args) is 0: + args += ['all'] + results = {} + benchmarks = [] #DaCapo - benchmarks = sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) + if ('dacapo' in args or 'all' in args): + benchmarks += sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) #Bootstrap - benchmarks += sanitycheck.getBootstraps() + if ('bootstrap' in args or 'all' in args): + benchmarks += sanitycheck.getBootstraps() #SPECjvm2008 - benchmarks += [sanitycheck.getSPECjvm2008(True, 60, 120)] + if ('specjvm2008' in args or 'all' in args): + benchmarks += [sanitycheck.getSPECjvm2008(True, 60, 120)] for test in benchmarks: if not results.has_key(test.group): results[test.group] = {} - results[test.group].update(test.bench('-graal')) - print results + results[test.group].update(test.bench('-' + vm)) + mx.log(json.dumps(results)) + if resultFile: + with open(resultFile, 'w') as f: + f.write(json.dumps(results)) def specjvm2008(args): sanitycheck.getSPECjvm2008().bench('-graal') @@ -534,7 +566,7 @@ 'specjvm2008': [specjvm2008, ''], 'example': [example, '[-v] example names...'], 'gate' : [gate, ''], - 'bench' : [bench, ''], + 'bench' : [bench, '[-vm vm] [-resultfile file] [all(default)|dacapo|specjvm2008|bootstrap]'], 'unittest' : [unittest, '[filters...]'], 'vm': [vm, '[-options] class [args...]'] } diff -r f8f262212aa4 -r 063ea022532c mx/outputparser.py --- a/mx/outputparser.py Thu Jan 12 16:08:41 2012 +0100 +++ b/mx/outputparser.py Fri Jan 13 16:11:18 2012 +0100 @@ -37,7 +37,7 @@ self.matchers.append(matcher) def parse(self, vm, cmd, cwd=None, vmbuild=None): - ret = [{}] + ret = [] def parseLine(line): anyMatch = False @@ -45,7 +45,7 @@ parsed = matcher.parse(line.strip()) if parsed: anyMatch = True - if matcher.startNewLine and len(ret[0]) > 0: + if len(ret) is 0 or (matcher.startNewLine and len(ret[len(ret)-1]) > 0): ret.append({}) ret[len(ret)-1].update(parsed) if anyMatch : diff -r f8f262212aa4 -r 063ea022532c mx/sanitycheck.py --- a/mx/sanitycheck.py Thu Jan 12 16:08:41 2012 +0100 +++ b/mx/sanitycheck.py Fri Jan 13 16:11:18 2012 +0100 @@ -120,7 +120,7 @@ return Test("DaCapo-" + name, "DaCapo", ['-jar', dacapo, name, '-n', str(n), ] + dacapoArgs, [dacapoSuccess], [dacapoFail], [dacapoMatcher], ['-Xms1g', '-Xmx2g', '-XX:MaxPermSize=256m']) def getBootstraps(): - time = re.compile(r"Bootstrapping Graal............... in (?P