comparison mx/commands.py @ 4157:b26279781d95

Simplified 'dacapo' command and made it more suitable for gate usage. Removed use of sanitycheck module.
author Doug Simon <doug.simon@oracle.com>
date Wed, 21 Dec 2011 17:24:39 +0100
parents 843c8d6720da
children e253ca26b2d5
comparison
equal deleted inserted replaced
4156:843c8d6720da 4157:b26279781d95
24 # or visit www.oracle.com if you need additional information or have any 24 # or visit www.oracle.com if you need additional information or have any
25 # questions. 25 # questions.
26 # 26 #
27 # ---------------------------------------------------------------------------------------------------- 27 # ----------------------------------------------------------------------------------------------------
28 28
29 import os, sys, shutil, StringIO, zipfile, tempfile 29 import os, sys, shutil, StringIO, zipfile, tempfile, re
30 from os.path import join, exists, dirname, isdir, isabs, basename 30 from os.path import join, exists, dirname, isdir, isfile, isabs, basename
31 from argparse import ArgumentParser, REMAINDER 31 from argparse import ArgumentParser, REMAINDER
32 import mx 32 import mx
33 import sanitycheck
34 33
35 _graal_home = dirname(dirname(__file__)) 34 _graal_home = dirname(dirname(__file__))
36 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) 35 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src'))
37 _vmbuild = 'product' 36 _vmbuild = 'product'
38 37
126 mx.log('--------- ' + a + ' ------------') 125 mx.log('--------- ' + a + ' ------------')
127 project, mainClass = config 126 project, mainClass = config
128 run_example(verbose, project, mainClass) 127 run_example(verbose, project, mainClass)
129 128
130 def dacapo(args): 129 def dacapo(args):
131 """run one or all DaCapo benchmarks""" 130 """run one or all DaCapo benchmarks
132 runs = dict() 131
133 while len(args) != 0 and not args[0].startswith('-'): 132 DaCapo options are distinguised from VM options by a '@' prefix.
133 For example, '@--iterations @5' will pass '--iterations 5' to the
134 DaCapo harness."""
135
136 benchmarks = [
137 'avrora',
138 'batik',
139 'eclipse',
140 'fop',
141 'h2',
142 'jython',
143 'luindex',
144 'lusearch',
145 'pmd',
146 'sunflow',
147 'tomcat',
148 'tradebeans',
149 'tradesoap',
150 'xalan'
151 ]
152
153 dacapo = mx.check_get_env('DACAPO_CP')
154 if not isfile(dacapo) or not dacapo.endswith('.jar'):
155 mx.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + dacapo)
156
157 vmOpts = ['-Xms1g', '-Xmx2g', '-cp', dacapo]
158
159 selected = []
160 while len(args) != 0 and args[0][0] not in ['-', '@']:
134 bm = args[0] 161 bm = args[0]
135 del args[0] 162 del args[0]
136 n = sanitycheck.dacapoSanityWarmup.get(bm)[sanitycheck.SanityCheckLevel.Normal] 163 if bm not in benchmarks:
137 if (n is None): 164 mx.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks))
138 mx.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(sanitycheck.dacapoSanityWarmup.keys())) 165 selected.append(bm)
139 runs[bm] = n 166
140 167 if len(selected) != 0:
141 if len(runs) == 0: 168 benchmarks = selected
142 for (key, ns) in sanitycheck.dacapoSanityWarmup.items(): 169
143 runs[key] = ns[sanitycheck.SanityCheckLevel.Normal] 170 # Extract DaCapo options
144 171 dacapoArgs = [(arg[1:]) for arg in args if arg.startswith('@')]
145 for (bench, n) in runs.items(): 172
146 vm(args + sanitycheck.getDacapoCmd(bench, n=n)) 173 # The remainder are VM options
147 174 vmOpts += [arg for arg in args if not arg.startswith('@')]
148 def sanitychecks(args): 175
149 """runs sanity checks""" 176 dacapoSuccess = re.compile(r"^===== DaCapo 9\.12 ([a-zA-Z0-9_]+) PASSED in ([0-9]+) msec =====$")
150 checks = sanitycheck.getSanityChecks(sanitycheck.SanityCheckLevel.Gate) 177 passed = []
151 for check in checks: 178
152 if not sanitycheck.runSanityCheck(check['cmd'], check['success']): 179 for bm in benchmarks:
153 mx.abort("Sanity checks FAILED") 180 def errFilter(line):
154 mx.log("Sanity checks PASSED") 181 if dacapoSuccess.match(line):
155 182 passed.append(bm)
183 sys.stderr.write(line)
184 vm(vmOpts + ['Harness'] + dacapoArgs + [bm], err=errFilter)
185
186 failed = list(set(benchmarks).difference(set(passed)))
187
188 if len(failed) != 0:
189 mx.abort('Benchmark failures: ' + str(failed))
190
156 def _jdk(build='product', create=False): 191 def _jdk(build='product', create=False):
157 """ 192 """
158 Get the JDK into which Graal is installed, creating it first if necessary. 193 Get the JDK into which Graal is installed, creating it first if necessary.
159 """ 194 """
160 jdk = join(_graal_home, 'jdk' + mx.java().version) 195 jdk = join(_graal_home, 'jdk' + mx.java().version)
373 def mx_init(): 408 def mx_init():
374 _vmbuild = 'product' 409 _vmbuild = 'product'
375 commands = { 410 commands = {
376 'clean': [clean, ''], 411 'clean': [clean, ''],
377 'build': [build, ''], 412 'build': [build, ''],
378 'dacapo': [dacapo, '[benchmark] [VM options]'], 413 'dacapo': [dacapo, '[benchmark] [VM options|DaCapo options]'],
379 'example': [example, '[-v] example names...'], 414 'example': [example, '[-v] example names...'],
380 'vm': [vm, '[-options] class [args...]'], 415 'vm': [vm, '[-options] class [args...]'],
381 'ideinit': [ideinit, ''] 416 'ideinit': [ideinit, '']
382 } 417 }
383 418
387 mx.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug VM') 422 mx.add_argument('--fastdebug', action='store_const', dest='vmbuild', const='fastdebug', help='select the fast debug VM')
388 mx.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM') 423 mx.add_argument('--optimized', action='store_const', dest='vmbuild', const='optimized', help='select the optimized VM')
389 424
390 commands.update({ 425 commands.update({
391 'export': [export, '[-options] [zipfile]'], 426 'export': [export, '[-options] [zipfile]'],
392 'build': [build, '[product|debug|fastdebug|optimized]'], 427 'build': [build, '[product|debug|fastdebug|optimized]']
393 'sanity' : [sanitychecks, ''],
394 }) 428 })
395 429
396 mx.commands.update(commands) 430 mx.commands.update(commands)
397 431
398 def mx_post_parse_cmd_line(opts): 432 def mx_post_parse_cmd_line(opts):