[PATCH 2 of 2] perf: introduce a `--contains` flag to the `perfdirstate` command
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Oct 11 22:20:43 EDT 2019
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1570523303 14400
# Tue Oct 08 04:28:23 2019 -0400
# Node ID e4fdafd357f36f40c99cc324be8c70d169e53558
# Parent 992c09636ae9d0543ea621305a71d6f9f77dc7dc
# EXP-Topic perf-dirstate
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e4fdafd357f3
perf: introduce a `--contains` flag to the `perfdirstate` command
The new flag benchmark a large amount of `filepath in dirstate` call. This will
be useful to compare the Python and Rust implementation of the dirstatemap.
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1104,6 +1104,8 @@ def perfdirs(ui, repo, **opts):
@command(b'perfdirstate', [
('', 'iteration', None,
b'benchmark a full iteration for the dirstate'),
+ ('', 'contains', None,
+ b'benchmark a large amount of `nf in dirstate` calls'),
] + formatteropts)
def perfdirstate(ui, repo, **opts):
"""benchmap the time of various distate operations
@@ -1117,12 +1119,25 @@ def perfdirstate(ui, repo, **opts):
b"a" in repo.dirstate
+ if opts['iteration'] and opts['contains']:
+ msg = 'only specify one of --iteration or --contains'
+ raise error.Abort(msg)
+
if opts['iteration']:
setup = None
dirstate = repo.dirstate
def d():
for f in dirstate:
pass
+ elif opts['contains']:
+ setup = None
+ dirstate = repo.dirstate
+ allfiles = list(dirstate)
+ # also add file path that will be "missing" from the dirstate
+ allfiles.extend([f[::-1] for f in allfiles])
+ def d():
+ for f in allfiles:
+ f in dirstate
else:
def setup():
repo.dirstate.invalidate()
diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -205,6 +205,7 @@ perfstatus
$ hg perfdirfoldmap
$ hg perfdirs
$ hg perfdirstate
+ $ hg perfdirstate --contains
$ hg perfdirstate --iteration
$ hg perfdirstatedirs
$ hg perfdirstatefoldmap
More information about the Mercurial-devel
mailing list