Skip to content

Commit 603fb98

Browse files
committed
benchmarks: allow abstract python vm to override number of iterations
- set a lower timeout for cpython running its own unittests
1 parent 7e9579b commit 603fb98

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

graalpython/com.oracle.graal.python.test/src/python_unittests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ def _fmt(t):
722722
# get cpython stats
723723
log(HR)
724724
log("[INFO] get cpython stats")
725-
cpy_results = run_unittests(unittests, flags.timeout, with_cpython=True)
725+
cpy_results = run_unittests(unittests, 60 * 5, with_cpython=True)
726726
cpy_stats = process_output('\n'.join(cpy_results))[-1]
727727

728728
# get graalpython stats

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,37 +122,36 @@ def run(self, cwd, args):
122122
return ret_code, out.data
123123

124124

125-
class AbstractPythonNoWarmupVm(AbstractPythonVm):
125+
class AbstractPythonIterationsControlVm(AbstractPythonVm):
126126
__metaclass__ = ABCMeta
127127

128-
def __init__(self, config_name, options=None, no_warmup=False):
129-
super(AbstractPythonNoWarmupVm, self).__init__(config_name, options)
130-
self._no_warmup = no_warmup
128+
def __init__(self, config_name, options=None, iterations=None):
129+
super(AbstractPythonIterationsControlVm, self).__init__(config_name, options)
130+
self._iterations = iterations
131131

132-
@staticmethod
133-
def remove_warmup_runs(args):
132+
def _override_iterations_args(self, args):
134133
_args = []
135134
i = 0
136135
while i < len(args):
137136
arg = args[i]
138137
_args.append(arg)
139138
if arg == '-i':
140-
_args.append('0')
139+
_args.append(str(self._iterations))
141140
i += 1
142141
i += 1
143142
return _args
144143

145144
def run(self, cwd, args):
146-
if self._no_warmup:
147-
args = AbstractPythonNoWarmupVm.remove_warmup_runs(args)
148-
return super(AbstractPythonNoWarmupVm, self).run(cwd, args)
145+
if isinstance(self._iterations, (int, long)):
146+
args = self._override_iterations_args(args)
147+
return super(AbstractPythonIterationsControlVm, self).run(cwd, args)
149148

150149

151-
class CPythonVm(AbstractPythonNoWarmupVm):
150+
class CPythonVm(AbstractPythonIterationsControlVm):
152151
PYTHON_INTERPRETER = "python3"
153152

154-
def __init__(self, config_name, options=None, virtualenv=None, no_warmup=False):
155-
super(CPythonVm, self).__init__(config_name, options=options, no_warmup=no_warmup)
153+
def __init__(self, config_name, options=None, virtualenv=None, iterations=False):
154+
super(CPythonVm, self).__init__(config_name, options=options, iterations=iterations)
156155
self._virtualenv = virtualenv
157156

158157
@property
@@ -165,11 +164,11 @@ def name(self):
165164
return VM_NAME_CPYTHON
166165

167166

168-
class PyPyVm(AbstractPythonNoWarmupVm):
167+
class PyPyVm(AbstractPythonIterationsControlVm):
169168
PYPY_INTERPRETER = "pypy3"
170169

171-
def __init__(self, config_name, options=None, no_warmup=False):
172-
super(PyPyVm, self).__init__(config_name, options=options, no_warmup=no_warmup)
170+
def __init__(self, config_name, options=None, iterations=False):
171+
super(PyPyVm, self).__init__(config_name, options=options, iterations=iterations)
173172

174173
@property
175174
def interpreter(self):

0 commit comments

Comments
 (0)