Skip to content

Commit

Permalink
Merge pull request graalvm#134 in G/mx from ~JOSEF.E.EISL_ORACLE.COM/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
zapster committed Jun 30, 2016
2 parents d32e139 + 7d08ef6 commit e78ce45
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13834,7 +13834,7 @@ def alarm_handler(signum, frame):
# no need to show the stack trace when the user presses CTRL-C
abort(1)

version = VersionSpec("5.32.0")
version = VersionSpec("5.33.0")

currentUmask = None

Expand Down
24 changes: 24 additions & 0 deletions mx_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,28 @@ def add_bm_suite(suite, mxsuite=None):


class Rule(object):
# the maximum size of a string field
max_string_field_length = 255

@staticmethod
def crop_front(prefix=""):
"""Returns a function that truncates a string at the start."""
assert len(prefix) < Rule.max_string_field_length
def _crop(path):
if len(path) < Rule.max_string_field_length:
return str(path)
return str(prefix + path[-(Rule.max_string_field_length-len(prefix)):])
return _crop

@staticmethod
def crop_back(suffix=""):
"""Returns a function that truncates a string at the end."""
assert len(suffix) < Rule.max_string_field_length
def _crop(path):
if len(path) < Rule.max_string_field_length:
return str(path)
return str(path[:Rule.max_string_field_length-len(suffix)] + suffix)
return _crop

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

0 comments on commit e78ce45

Please sign in to comment.