changeset 4283:a9a63d4b0414

Merge
author Gilles Duboscq <gilles.m.duboscq@gmail.com>
date Fri, 13 Jan 2012 16:11:34 +0100
parents 62cb0e636094 (current diff) 063ea022532c (diff)
children 1339f1817d28
files
diffstat 3 files changed, 41 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mx/commands.py	Thu Jan 12 13:48:27 2012 -0800
+++ b/mx/commands.py	Fri Jan 13 16:11:34 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...]']
     }
--- a/mx/outputparser.py	Thu Jan 12 13:48:27 2012 -0800
+++ b/mx/outputparser.py	Fri Jan 13 16:11:34 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 :
--- a/mx/sanitycheck.py	Thu Jan 12 13:48:27 2012 -0800
+++ b/mx/sanitycheck.py	Fri Jan 13 16:11:34 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<time>[0-9]+) ms")
+    time = re.compile(r"Bootstrapping Graal\.+ in (?P<time>[0-9]+) ms")
     scoreMatcher = Matcher(time, {'const:name' : 'const:BootstrapTime', 'const:score' : 'time'})
     tests = []
     tests.append(Test("Bootstrap", "Bootstrap", ['-version'], successREs=[time], scoreMatchers=[scoreMatcher]))