Patchwork [1,of,6,V3] perf: add a perfignore command

login
register
mail settings
Submitter Boris Feld
Date Nov. 23, 2018, 2:12 p.m.
Message ID <917fa088dd67d1f56c75.1542982364@localhost.localdomain>
Download mbox | patch
Permalink /patch/36743/
State Accepted
Headers show

Comments

Boris Feld - Nov. 23, 2018, 2:12 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542916813 -3600
#      Thu Nov 22 21:00:13 2018 +0100
# Node ID 917fa088dd67d1f56c751de59acc91abc799d83a
# Parent  efd0f79246e3e6633dfd06226464a48584f69b19
# EXP-Topic perf-ignore
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 917fa088dd67
perf: add a perfignore command

The command is meant to benchmark operations related to hgignore. Right now the
command is benchmarking the loading time of the hgignore rules.
Yuya Nishihara - Nov. 28, 2018, 11:39 a.m.
On Fri, 23 Nov 2018 15:12:44 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1542916813 -3600
> #      Thu Nov 22 21:00:13 2018 +0100
> # Node ID 917fa088dd67d1f56c751de59acc91abc799d83a
> # Parent  efd0f79246e3e6633dfd06226464a48584f69b19
> # EXP-Topic perf-ignore
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 917fa088dd67
> perf: add a perfignore command

Queued only this patch, thanks.

Per discussion in the V2 thread, we aren't sure if it's still needed to
combine patterns into a single large regexp.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -961,6 +961,23 @@  def perfchangeset(ui, repo, rev, **opts)
     timer(d)
     fm.end()
 
+@command(b'perfignore', formatteropts)
+def perfignore(ui, repo, **opts):
+    """benchmark operation related to computing ignore"""
+    opts = _byteskwargs(opts)
+    timer, fm = gettimer(ui, opts)
+    dirstate = repo.dirstate
+
+    def setupone():
+        dirstate.invalidate()
+        clearfilecache(dirstate, b'_ignore')
+
+    def runone():
+        dirstate._ignore
+
+    timer(runone, setup=setupone, title="load")
+    fm.end()
+
 @command(b'perfindex', formatteropts)
 def perfindex(ui, repo, **opts):
     import mercurial.revlog
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
@@ -83,6 +83,7 @@  perfstatus
    perffncachewrite
                  (no help text available)
    perfheads     (no help text available)
+   perfignore    benchmark operation related to computing ignore
    perfindex     (no help text available)
    perflinelogedits
                  (no help text available)
@@ -161,6 +162,7 @@  perfstatus
   fncache already up to date
 #endif
   $ hg perfheads
+  $ hg perfignore
   $ hg perfindex
   $ hg perflinelogedits -n 1
   $ hg perfloadmarkers