Skip to content
Snippets Groups Projects
Commit 3059353cac32 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

benchmark: add a perfextjson method to return richer data

This makes it possible to handle `perf` command returning multiple value.
parent ebb202040808
No related branches found
No related tags found
No related merge requests found
......@@ -251,6 +251,36 @@
raise ValueError("Invalid output {0}".format(output))
return float(match.group(1))
def perfextjson(self, command, *args, **kwargs):
"""Use contrib/perf.py extension from mercurial to get a benchmark result"""
args = ['--template', 'json', '--config', 'perf.all-timing=yes'] + list(args)
output = self._perfext(command, *args, **kwargs)
if output is None:
return None
try:
data = json.loads(output)
except ValueError:
return None
result = {}
for item in data:
title = item.get("title")
if title in result:
# multiple conflicting entry, skipping this one
print("ignoring duplicated entry in json output:", title,
file=sys.stderr)
continue
result[title] = localdata = {
"count": item.get("count"),
"minimum": item.get("wall"),
}
if 'median.wall' in item:
localdata['median'] = item['median.wall']
if 'avg.wall' in item:
localdata['average'] = item['avg.wall']
if 'max.wall' in item:
localdata['maximum'] = item['max.wall']
return result
def setup(self, repo, *args, **kwargs):
venv = os.path.abspath(os.path.join(os.path.dirname(sys.executable), ".."))
self.repo_name = repo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment