# HG changeset patch # User Pierre-Yves David # Date 1570522984 14400 # Node ID 5f9b1250b82a405cc29a0697529b64932c4a7023 # Parent 86b26f20146d9394582b172ffcb5fcb92739d1e7 perf: introduce a `--iteration` to `perfdirstate` This flag benchmark an iteration over all the file in the dirstate. This will be useful to compare the Python and the Rust implementation of the dirstate. diff -r 86b26f20146d -r 5f9b1250b82a contrib/perf.py --- a/contrib/perf.py Sun Oct 13 00:15:36 2019 -0400 +++ b/contrib/perf.py Tue Oct 08 04:23:04 2019 -0400 @@ -1101,10 +1101,14 @@ fm.end() -@command(b'perfdirstate', formatteropts) +@command(b'perfdirstate', [ + (b'', b'iteration', None, + b'benchmark a full iteration for the dirstate'), + ] + formatteropts) def perfdirstate(ui, repo, **opts): - """benchmap the time necessary to load a dirstate from scratch - + """benchmap the time of various distate operations + + By default benchmark the time necessary to load a dirstate from scratch. The dirstate is loaded to the point were a "contains" request can be answered. """ @@ -1112,11 +1116,18 @@ timer, fm = gettimer(ui, opts) b"a" in repo.dirstate - def setup(): - repo.dirstate.invalidate() - - def d(): - b"a" in repo.dirstate + if opts[b'iteration']: + setup = None + dirstate = repo.dirstate + def d(): + for f in dirstate: + pass + else: + def setup(): + repo.dirstate.invalidate() + + def d(): + b"a" in repo.dirstate timer(d, setup=setup) fm.end() diff -r 86b26f20146d -r 5f9b1250b82a tests/test-contrib-perf.t --- a/tests/test-contrib-perf.t Sun Oct 13 00:15:36 2019 -0400 +++ b/tests/test-contrib-perf.t Tue Oct 08 04:23:04 2019 -0400 @@ -107,7 +107,7 @@ perfdirfoldmap benchmap a 'dirstate._map.dirfoldmap.get()' request perfdirs (no help text available) - perfdirstate benchmap the time necessary to load a dirstate from scratch + perfdirstate benchmap the time of various distate operations perfdirstatedirs benchmap a 'dirstate.hasdir' call from an empty 'dirs' cache perfdirstatefoldmap @@ -205,6 +205,7 @@ $ hg perfdirfoldmap $ hg perfdirs $ hg perfdirstate + $ hg perfdirstate --iteration $ hg perfdirstatedirs $ hg perfdirstatefoldmap $ hg perfdirstatewrite