Patchwork D4148: perf: add a command to benchmark linelog edits

login
register
mail settings
Submitter phabricator
Date Aug. 9, 2018, 6:07 p.m.
Message ID <7227ddf38e341040b01a7d053799869c@localhost.localdomain>
Download mbox | patch
Permalink /patch/33485/
State Not Applicable
Headers show

Comments

phabricator - Aug. 9, 2018, 6:07 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1601afbb573c: perf: add a command to benchmark linelog edits (authored by quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4148?vs=10065&id=10133

REVISION DETAIL
  https://phab.mercurial-scm.org/D4148

AFFECTED FILES
  contrib/perf.py
  tests/test-contrib-perf.t

CHANGE DETAILS




To: quark, #hg-reviewers, durin42
Cc: durin42, indygreg, mercurial-devel

Patch

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
@@ -82,6 +82,8 @@ 
                  (no help text available)
    perfheads     (no help text available)
    perfindex     (no help text available)
+   perflinelogedits
+                 (no help text available)
    perfloadmarkers
                  benchmark the time to parse the on-disk markers for a repo
    perflog       (no help text available)
@@ -154,6 +156,7 @@ 
 #endif
   $ hg perfheads
   $ hg perfindex
+  $ hg perflinelogedits -n 1
   $ hg perfloadmarkers
   $ hg perflog
   $ hg perflookup 2
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -889,6 +889,38 @@ 
     timer(lambda: len(repo.lookup(rev)))
     fm.end()
 
+@command('perflinelogedits',
+         [('n', 'edits', 10000, 'number of edits'),
+          ('', 'max-hunk-lines', 10, 'max lines in a hunk'),
+         ], norepo=True)
+def perflinelogedits(ui, **opts):
+    from mercurial import linelog
+
+    edits = opts['edits']
+    maxhunklines = opts['max_hunk_lines']
+
+    maxb1 = 100000
+    random.seed(0)
+    randint = random.randint
+    currentlines = 0
+    arglist = []
+    for rev in xrange(edits):
+        a1 = randint(0, currentlines)
+        a2 = randint(a1, min(currentlines, a1 + maxhunklines))
+        b1 = randint(0, maxb1)
+        b2 = randint(b1, b1 + maxhunklines)
+        currentlines += (b2 - b1) - (a2 - a1)
+        arglist.append((rev, a1, a2, b1, b2))
+
+    def d():
+        ll = linelog.linelog()
+        for args in arglist:
+            ll.replacelines(*args)
+
+    timer, fm = gettimer(ui, opts)
+    timer(d)
+    fm.end()
+
 @command('perfrevrange', formatteropts)
 def perfrevrange(ui, repo, *specs, **opts):
     timer, fm = gettimer(ui, opts)