Mercurial > public > mercurial-scm > hg-stable
diff contrib/benchmarks/__init__.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | be0e7af80543 |
children | 9d2b2df2c2ba |
line wrap: on
line diff
--- a/contrib/benchmarks/__init__.py Sat Oct 05 10:29:34 2019 -0400 +++ b/contrib/benchmarks/__init__.py Sun Oct 06 09:45:02 2019 -0400 @@ -44,15 +44,24 @@ util, ) -basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), - os.path.pardir, os.path.pardir)) +basedir = os.path.abspath( + os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir) +) reposdir = os.environ['REPOS_DIR'] -reposnames = [name for name in os.listdir(reposdir) - if os.path.isdir(os.path.join(reposdir, name, ".hg"))] +reposnames = [ + name + for name in os.listdir(reposdir) + if os.path.isdir(os.path.join(reposdir, name, ".hg")) +] if not reposnames: raise ValueError("No repositories found in $REPO_DIR") -outputre = re.compile((r'! wall (\d+.\d+) comb \d+.\d+ user \d+.\d+ sys ' - r'\d+.\d+ \(best of \d+\)')) +outputre = re.compile( + ( + r'! wall (\d+.\d+) comb \d+.\d+ user \d+.\d+ sys ' + r'\d+.\d+ \(best of \d+\)' + ) +) + def runperfcommand(reponame, command, *args, **kwargs): os.environ["HGRCPATH"] = os.environ.get("ASVHGRCPATH", "") @@ -63,8 +72,9 @@ else: ui = uimod.ui() repo = hg.repository(ui, os.path.join(reposdir, reponame)) - perfext = extensions.load(ui, 'perfext', - os.path.join(basedir, 'contrib', 'perf.py')) + perfext = extensions.load( + ui, 'perfext', os.path.join(basedir, 'contrib', 'perf.py') + ) cmd = getattr(perfext, command) ui.pushbuffer() cmd(ui, repo, *args, **kwargs) @@ -74,6 +84,7 @@ raise ValueError("Invalid output {0}".format(output)) return float(match.group(1)) + def perfbench(repos=reposnames, name=None, params=None): """decorator to declare ASV benchmark based on contrib/perf.py extension @@ -104,10 +115,12 @@ def wrapped(repo, *args): def perf(command, *a, **kw): return runperfcommand(repo, command, *a, **kw) + return func(perf, *args) wrapped.params = [p[1] for p in params] wrapped.param_names = [p[0] for p in params] wrapped.pretty_name = name return wrapped + return decorator