D4148: perf: add a command to benchmark linelog edits
quark (Jun Wu)
phabricator at mercurial-scm.org
Tue Aug 7 02:00:10 UTC 2018
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
The use pattern of creating a linelog is usually by calling "replacelines"
multiple times. Add a command to benchmark it.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4148
AFFECTED FILES
contrib/perf.py
CHANGE DETAILS
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -889,6 +889,34 @@
timer(lambda: len(repo.lookup(rev)))
fm.end()
+ at 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']
+
+ def d():
+ maxb1 = 100000
+ random.seed(0)
+ randint = random.randint
+ currentlines = 0
+ ll = linelog.linelog()
+ 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)
+ ll.replacelines(rev, a1, a2, b1, b2)
+
+ timer, fm = gettimer(ui, opts)
+ timer(d)
+ fm.end()
+
@command('perfrevrange', formatteropts)
def perfrevrange(ui, repo, *specs, **opts):
timer, fm = gettimer(ui, opts)
To: quark, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list