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

login
register
mail settings
Submitter Boris Feld
Date Nov. 22, 2018, 10:17 p.m.
Message ID <98300756a74d424fcd15.1542925038@localhost.localdomain>
Download mbox | patch
Permalink /patch/36723/
State Superseded
Headers show

Comments

Boris Feld - Nov. 22, 2018, 10:17 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 98300756a74d424fcd1510b0bb98f07b9b0f8663
# Parent  efd0f79246e3e6633dfd06226464a48584f69b19
# EXP-Topic perf-ignore-2
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 98300756a74d
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.

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