# HG changeset patch # User Pierre-Yves David # Date 2019-11-03 23:16:44 # Node ID eabc5eec3aba0366068a1d6bc42349f2f9b196bd # Parent fb5c72501de2451a9c785da2912267565ad53cc6 perf: add a way to benchmark `dirstate.status` Getting more details about time spend in this specific internal bit is meaningful. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -760,7 +760,10 @@ def perfannotate(ui, repo, f, **opts): @command( b'perfstatus', - [(b'u', b'unknown', False, b'ask status to look for unknown files')] + [ + (b'u', b'unknown', False, b'ask status to look for unknown files'), + (b'', b'dirstate', False, b'benchmark the internal dirstate call'), + ] + formatteropts, ) def perfstatus(ui, repo, **opts): @@ -776,7 +779,20 @@ def perfstatus(ui, repo, **opts): # timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, # False)))) timer, fm = gettimer(ui, opts) - timer(lambda: sum(map(len, repo.status(unknown=opts[b'unknown'])))) + if opts[b'dirstate']: + dirstate = repo.dirstate + m = scmutil.matchall(repo) + unknown = opts[b'unknown'] + + def status_dirstate(): + s = dirstate.status( + m, subrepos=[], ignored=False, clean=False, unknown=unknown + ) + sum(map(len, s)) + + timer(status_dirstate) + else: + timer(lambda: sum(map(len, repo.status(unknown=opts[b'unknown'])))) fm.end() 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 @@ -248,6 +248,7 @@ perfstatus $ hg perfrevset 'all()' $ hg perfstartup $ hg perfstatus + $ hg perfstatus --dirstate $ hg perftags $ hg perftemplating $ hg perfvolatilesets