Skip to content

Commit 371f4c1

Browse files
committed
benchmarking: cpytonvm - allow alteration of args to restrict the execution without warmup runs
- fix the bench suite error pattern for the cases where truffle compilation details are logged
1 parent d2d7576 commit 371f4c1

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ def run(self, cwd, args):
125125
class CPythonVm(AbstractPythonVm):
126126
PYTHON_INTERPRETER = "python3"
127127

128-
def __init__(self, config_name, options=None, virtualenv=None):
128+
def __init__(self, config_name, options=None, virtualenv=None, no_warmup=False):
129129
super(CPythonVm, self).__init__(config_name, options)
130130
self._virtualenv = virtualenv
131+
self._no_warmup = no_warmup
131132

132133
@property
133134
def interpreter(self):
@@ -138,6 +139,24 @@ def interpreter(self):
138139
def name(self):
139140
return VM_NAME_CPYTHON
140141

142+
@staticmethod
143+
def remove_warmup_runs(args):
144+
_args = []
145+
i = 0
146+
while i < len(args):
147+
arg = args[i]
148+
_args.append(arg)
149+
if arg == '-i':
150+
_args.append('0')
151+
i += 1
152+
i += 1
153+
return _args
154+
155+
def run(self, cwd, args):
156+
if self._no_warmup:
157+
args = CPythonVm.remove_warmup_runs(args)
158+
return super(CPythonVm, self).run(cwd, args)
159+
141160

142161
class PyPyVm(AbstractPythonVm):
143162
def __init__(self, config_name, options=None):
@@ -321,7 +340,8 @@ def successPatterns(self):
321340

322341
def failurePatterns(self):
323342
return [
324-
re.compile(r"Exception")
343+
# lookahead pattern for when truffle compilation details are enabled in the log
344+
re.compile(r"^(?!(\[truffle\])).*Exception")
325345
]
326346

327347
def group(self):

0 commit comments

Comments
 (0)