# HG changeset patch # User Pierre-Yves David <pierre-yves.da...@octobus.net> # Date 1570523303 14400 # Tue Oct 08 04:28:23 2019 -0400 # Node ID c048894d3616efa28ee45979be12780260a7fed3 # Parent 397c7843d0261382d642b2e02b2685ab9367d6bb # EXP-Topic perf-doc # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c048894d3616 perf: introduce a `perfdirstatecontains` command
The new command 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 @@ -1122,6 +1122,26 @@ def perfdirstate(ui, repo, **opts): fm.end() +@command(b'perfdirstatecontains', formatteropts) +def perfdirstatecontains(ui, repo, **opts): + """benchmap contains check for all file in the dirstate + """ + opts = _byteskwargs(opts) + timer, fm = gettimer(ui, opts) + dirstate = repo.dirstate + b'a' in 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 + + timer(d) + fm.end() + + @command(b'perfdirstatedirs', formatteropts) def perfdirstatedirs(ui, repo, **opts): """benchmap a 'dirstate.hasdir' call from an empty `dirs` cache 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 @@ -108,6 +108,8 @@ perfstatus benchmap a 'dirstate._map.dirfoldmap.get()' request perfdirs (no help text available) perfdirstate benchmap the time necessary to load a dirstate from scratch + perfdirstatecontains + benchmap contains check for all file in the dirstate perfdirstatedirs benchmap a 'dirstate.hasdir' call from an empty 'dirs' cache perfdirstatefoldmap @@ -207,6 +209,7 @@ perfstatus $ hg perfdirfoldmap $ hg perfdirs $ hg perfdirstate + $ hg perfdirstatecontains $ hg perfdirstatedirs $ hg perfdirstatefoldmap $ hg perfdirstateiter _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel