Skip to content

Commit 62eeffc

Browse files
committed
make it easy to run meso benchmarks on jython
1 parent d5508b7 commit 62eeffc

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

graalpython/com.oracle.graal.python.benchmarks/python/harness.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import _io
4141
import os
4242
import sys
43+
import types
4344
from time import time
4445

4546

@@ -229,7 +230,7 @@ def get_bench_module(bench_file):
229230
return bench_module
230231

231232
else:
232-
bench_module = type(sys)(name, bench_file)
233+
bench_module = types.ModuleType(name, bench_file)
233234
with _io.FileIO(bench_file, "r") as f:
234235
bench_module.__file__ = bench_file
235236
bench_module.ccompile = ccompile
@@ -256,7 +257,10 @@ def run(self):
256257
args = self._call_attr(ATTR_PROCESS_ARGS, *self.bench_args)
257258
if args is None:
258259
# default args processor considers all args as ints
259-
args = list(map(int, self.bench_args))
260+
if sys.version_info.major < 3:
261+
args = list(map(lambda x: int(x.replace("_", "")), self.bench_args))
262+
else:
263+
args = list(map(int, self.bench_args))
260264

261265
print("### args = ", args)
262266
print(_HRULE)

graalpython/com.oracle.graal.python.benchmarks/python/meso/meteor3.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#
4242
# contributed by Daniel Nanz, 2008-08-21
4343
# 2to3
44+
from __future__ import print_function
4445
from bisect import bisect
4546
import time
4647

@@ -181,7 +182,7 @@ def main(n):
181182

182183
def measure(num):
183184
main(num)
184-
185+
185186

186187
def __benchmark__(num=2098):
187188
measure(num)

graalpython/com.oracle.graal.python.benchmarks/python/meso/richards3.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
# Translation from C++, Mario Wolczko
4646
# Outer loop added by Alex Jacoby
4747

48+
from __future__ import print_function
49+
4850
# Task IDs
4951
I_IDLE = 1
5052
I_WORK = 2

mx.graalpython/mx_graalpython.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import mx_urlrewrites
5353
from mx_gate import Task
5454
from mx_graalpython_bench_param import PATH_MESO, BENCHMARKS, JBENCHMARKS
55-
from mx_graalpython_benchmark import PythonBenchmarkSuite, python_vm_registry, CPythonVm, PyPyVm, GraalPythonVm, \
55+
from mx_graalpython_benchmark import PythonBenchmarkSuite, python_vm_registry, CPythonVm, PyPyVm, JythonVm, GraalPythonVm, \
5656
CONFIGURATION_DEFAULT, CONFIGURATION_SANDBOXED, CONFIGURATION_NATIVE, \
5757
CONFIGURATION_DEFAULT_MULTI, CONFIGURATION_SANDBOXED_MULTI, CONFIGURATION_NATIVE_MULTI, \
5858
PythonInteropBenchmarkSuite
@@ -1286,6 +1286,9 @@ def _register_vms(namespace):
12861286
# pypy
12871287
python_vm_registry.add_vm(PyPyVm(config_name=CONFIGURATION_DEFAULT), SUITE)
12881288

1289+
# jython
1290+
python_vm_registry.add_vm(JythonVm(config_name=CONFIGURATION_DEFAULT), SUITE)
1291+
12891292
# graalpython
12901293
python_vm_registry.add_vm(GraalPythonVm(config_name=CONFIGURATION_DEFAULT), SUITE, 10)
12911294
python_vm_registry.add_vm(GraalPythonVm(config_name=CONFIGURATION_DEFAULT_MULTI, extra_polyglot_args=[

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
VM_NAME_GRAALPYTHON = "graalpython"
5252
VM_NAME_CPYTHON = "cpython"
5353
VM_NAME_PYPY = "pypy"
54+
VM_NAME_JYTHON = "jython"
5455
VM_NAME_GRAALPYTHON_SVM = "graalpython-svm"
5556
GROUP_GRAAL = "Graal"
5657
SUBGROUP_GRAAL_PYTHON = "graalpython"
@@ -245,6 +246,27 @@ def name(self):
245246
return VM_NAME_PYPY
246247

247248

249+
class JythonVm(AbstractPythonIterationsControlVm):
250+
JYTHON_INTERPRETER = "jython"
251+
252+
def __init__(self, config_name, options=None, env=None, iterations=None):
253+
super(JythonVm, self).__init__(config_name, options=options, env=env, iterations=iterations)
254+
255+
def override_iterations(self, requested_iterations):
256+
return 2
257+
258+
@property
259+
def interpreter(self):
260+
try:
261+
return subprocess.check_output("which %s" % JythonVm.JYTHON_INTERPRETER, shell=True).decode().strip()
262+
except OSError:
263+
mx.abort("{} is not set!".format(ENV_JYTHON_HOME))
264+
return join(home, 'bin', JythonVm.JYTHON_INTERPRETER)
265+
266+
def name(self):
267+
return VM_NAME_JYTHON
268+
269+
248270
class GraalPythonVm(GuestVm):
249271
def __init__(self, config_name=CONFIGURATION_DEFAULT, distributions=None, cp_suffix=None, cp_prefix=None,
250272
host_vm=None, extra_vm_args=None, extra_polyglot_args=None, env=None):

0 commit comments

Comments
 (0)