changeset 43436:bfc68404cccd

perf: add a way to benchmark `dirstate.status` Getting more details about time spend in this specific internal bit is meaningful.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 04 Nov 2019 00:16:44 +0100
parents 0371a8c84827
children 93f74a7d3f07
files contrib/perf.py tests/test-contrib-perf.t
diffstat 2 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Thu Oct 24 11:12:17 2019 -0700
+++ b/contrib/perf.py	Mon Nov 04 00:16:44 2019 +0100
@@ -760,7 +760,10 @@
 
 @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 @@
     # 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()
 
 
--- a/tests/test-contrib-perf.t	Thu Oct 24 11:12:17 2019 -0700
+++ b/tests/test-contrib-perf.t	Mon Nov 04 00:16:44 2019 +0100
@@ -248,6 +248,7 @@
   $ hg perfrevset 'all()'
   $ hg perfstartup
   $ hg perfstatus
+  $ hg perfstatus --dirstate
   $ hg perftags
   $ hg perftemplating
   $ hg perfvolatilesets