Skip to content

Commit e78ce45

Browse files
committed
Merge pull request graalvm#134 in G/mx from ~JOSEF.E.EISL_ORACLE.COM/mx:mx-benchmark-conv-value to master
* commit '7d08ef6102b0d103742855f93a08d3a94dfc0e09': Bump version to 5.33.0 mx benchmark: add max_string_field_length and cropping functions mx benchmark: add support for custom value formatting functions
2 parents d32e139 + 7d08ef6 commit e78ce45

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

mx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13834,7 +13834,7 @@ def alarm_handler(signum, frame):
1383413834
# no need to show the stack trace when the user presses CTRL-C
1383513835
abort(1)
1383613836

13837-
version = VersionSpec("5.32.0")
13837+
version = VersionSpec("5.33.0")
1383813838

1383913839
currentUmask = None
1384013840

mx_benchmark.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,28 @@ def add_bm_suite(suite, mxsuite=None):
162162

163163

164164
class Rule(object):
165+
# the maximum size of a string field
166+
max_string_field_length = 255
167+
168+
@staticmethod
169+
def crop_front(prefix=""):
170+
"""Returns a function that truncates a string at the start."""
171+
assert len(prefix) < Rule.max_string_field_length
172+
def _crop(path):
173+
if len(path) < Rule.max_string_field_length:
174+
return str(path)
175+
return str(prefix + path[-(Rule.max_string_field_length-len(prefix)):])
176+
return _crop
177+
178+
@staticmethod
179+
def crop_back(suffix=""):
180+
"""Returns a function that truncates a string at the end."""
181+
assert len(suffix) < Rule.max_string_field_length
182+
def _crop(path):
183+
if len(path) < Rule.max_string_field_length:
184+
return str(path)
185+
return str(path[:Rule.max_string_field_length-len(suffix)] + suffix)
186+
return _crop
165187

166188
def parse(self, text):
167189
"""Create a dictionary of variables for every measurment.
@@ -241,6 +263,8 @@ def var(name):
241263
inst = float(v)
242264
elif vtype is bool:
243265
inst = bool(v)
266+
elif hasattr(vtype, '__call__'):
267+
inst = vtype(v)
244268
else:
245269
raise RuntimeError("Cannot handle type {0}".format(vtype))
246270
if type(inst) not in [str, int, float, bool]:

0 commit comments

Comments
 (0)