# HG changeset patch # User Pierre-Yves David # Date 1570523303 14400 # Node ID 0c4efb6eb4fa84d2270cbef68b05f6d167858ff6 # Parent 5f9b1250b82a405cc29a0697529b64932c4a7023 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 -r 5f9b1250b82a -r 0c4efb6eb4fa contrib/perf.py --- a/contrib/perf.py Tue Oct 08 04:23:04 2019 -0400 +++ b/contrib/perf.py Tue Oct 08 04:28:23 2019 -0400 @@ -1101,10 +1101,24 @@ fm.end() -@command(b'perfdirstate', [ - (b'', b'iteration', None, - b'benchmark a full iteration for the dirstate'), - ] + formatteropts) +@command( + b'perfdirstate', + [ + ( + b'', + b'iteration', + None, + b'benchmark a full iteration for the dirstate', + ), + ( + b'', + b'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 @@ -1116,13 +1130,31 @@ timer, fm = gettimer(ui, opts) b"a" in repo.dirstate + if opts[b'iteration'] and opts[b'contains']: + msg = b'only specify one of --iteration or --contains' + raise error.Abort(msg) + if opts[b'iteration']: setup = None dirstate = repo.dirstate + def d(): for f in dirstate: pass + + elif opts[b'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 -r 5f9b1250b82a -r 0c4efb6eb4fa tests/test-contrib-perf.t --- a/tests/test-contrib-perf.t Tue Oct 08 04:23:04 2019 -0400 +++ b/tests/test-contrib-perf.t Tue Oct 08 04:28:23 2019 -0400 @@ -205,6 +205,7 @@ $ hg perfdirfoldmap $ hg perfdirs $ hg perfdirstate + $ hg perfdirstate --contains $ hg perfdirstate --iteration $ hg perfdirstatedirs $ hg perfdirstatefoldmap