-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathdacapo.py
113 lines (98 loc) · 4.52 KB
/
dacapo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import os
import re
import logging
import shutil
from autotest.client import utils, test
from autotest.client.test_config import config_loader
from autotest.client.shared import error, software_manager
class dacapo(test.test):
"""
This autotest module runs the dacapo benchmark suite.
This benchmark suite is intended as a tool for Java benchmarking by the
programming language, memory management and computer architecture
communities. It consists of a set of open source, real world applications
with non-trivial memory loads. The suite is the culmination of over five
years work at eight institutions, as part of the DaCapo research project,
which was funded by a National Science Foundation ITR Grant, CCR-0085792.
@author: Lucas Meneghel Rodrigues ([email protected])
@see: http://dacapobench.org/
"""
version = 2
def set_java_environment(self, jvm, java_root):
"""
Setup java environment variables (path and classpath in order to
execute a specific jvm specified by the java_root variable.
java_root - Base of the java vm installation
"""
if jvm.startswith('ibm'):
java_home = os.path.join(java_root, 'jre')
else:
java_home = java_root
java_bin = os.path.join(java_home, 'bin')
java_lib = os.path.join(java_home, 'lib')
os.environ['JAVA_ROOT'] = java_root
os.environ['JAVA_HOME'] = java_home
os.environ['JRE_HOME'] = java_home
os.environ['CLASSPATH'] = java_lib
os.environ['JAVA_BINDIR'] = java_bin
os.environ['PATH'] = java_bin + ':' + os.environ['PATH']
def run_once(self, test='antlr', config='./dacapo.cfg', jvm='default'):
cfg = config_loader(cfg=config, tmpdir=self.tmpdir, raise_errors=True)
self.test = test
cachedir = os.path.join(os.path.dirname(self.srcdir), 'cache')
if not os.path.isdir(cachedir):
os.makedirs(cachedir)
dacapo_url = cfg.get('dacapo', 'tarball_url')
dacapo_md5 = cfg.get('dacapo', 'package_md5')
dacapo_pkg = utils.unmap_url_cache(cachedir, dacapo_url, dacapo_md5)
if not jvm == 'default':
# Get the jvm package
jvm_pkg_url = cfg.get(jvm, 'jvm_pkg_url')
jvm_pkg_md5 = cfg.get(jvm, 'package_md5')
jvm_pkg = utils.unmap_url_cache(cachedir, jvm_pkg_url, jvm_pkg_md5)
# Install it
swman = software_manager.SoftwareManager()
swman.install(jvm_pkg)
# Basic Java environment variables setup
java_root = cfg.get(jvm, 'java_root')
self.set_java_environment(jvm, java_root)
if cfg.get('global', 'use_global') == 'yes':
iterations = cfg.get('global', 'iterations')
workload = cfg.get('global', 'workload')
else:
iterations = cfg.get(test, 'iterations')
workload = cfg.get(test, 'workload')
verbose = '-v '
workload = '-s %s ' % workload
iterations = '-n %s ' % iterations
self.scratch = os.path.join(self.resultsdir, test)
scratch = '--scratch-directory %s ' % self.scratch
args = verbose + workload + scratch + iterations + test
self.raw_result_file = os.path.join(self.resultsdir,
'raw_output_%s' % self.iteration)
raw_result = open(self.raw_result_file, 'w')
logging.info('Running dacapo benchmark %s', test)
try:
cmd = 'java -jar %s %s' % (dacapo_pkg, args)
results = utils.run(command=cmd, stdout_tee=raw_result,
stderr_tee=raw_result)
self.results = results.stderr
raw_result.close()
except error.CmdError, e:
raise error.TestError('Dacapo benchmark %s has failed: %s' %
(test, e))
def postprocess_iteration(self):
result_line = self.results.splitlines()[-1]
time_regexp = re.compile('PASSED in (\d+) ms')
matches = time_regexp.findall(result_line)
if len(matches) == 1:
keylist = {}
logging.info('Benchmark %s completed in %s ms', self.test,
matches[0])
keylist[self.test] = int(matches[0])
self.write_perf_keyval(keylist)
# Remove scratch directory
shutil.rmtree(self.scratch)
else:
logging.error('Problems executing benchmark %s, not recording '
'results on the perf keyval', self.test)