# HG changeset patch # User Patrick Mezard # Date 1257955320 -3600 # Node ID d768614578dded2bfcd2f583b845ca25588cf036 # Parent 0d850f8beea68e7c6f7f312148546900cfc58898 contrib/perf: profile diff of working directory changes diff -r 0d850f8beea6 -r d768614578dd contrib/perf.py --- a/contrib/perf.py Wed Nov 04 13:44:15 2009 -0600 +++ b/contrib/perf.py Wed Nov 11 17:02:00 2009 +0100 @@ -4,7 +4,7 @@ from mercurial import cmdutil, match, commands import time, os, sys -def timer(func): +def timer(func, title=None): results = [] begin = time.time() count = 0 @@ -21,6 +21,8 @@ break if cstop - begin > 10 and count >= 3: break + if title: + sys.stderr.write("! %s\n" % title) if r: sys.stderr.write("! result: %s\n" % r) m = min(results) @@ -113,6 +115,23 @@ ' {author|person}: {desc|firstline}\n')) ui.popbuffer() +def perfdiffwd(ui, repo): + """Profile diff of working directory changes""" + options = { + 'w': 'ignore_all_space', + 'b': 'ignore_space_change', + 'B': 'ignore_blank_lines', + } + + for diffopt in ('', 'w', 'b', 'B', 'wB'): + opts = dict((options[c], '1') for c in diffopt) + def d(): + ui.pushbuffer() + commands.diff(ui, repo, **opts) + ui.popbuffer() + title = 'diffopts: %s' % (diffopt and ('-' + diffopt) or 'none') + timer(d, title) + cmdtable = { 'perflookup': (perflookup, []), 'perfparents': (perfparents, []), @@ -127,5 +146,6 @@ 'perfdirstatedirs': (perfdirstate, []), 'perflog': (perflog, []), 'perftemplating': (perftemplating, []), + 'perfdiffwd': (perfdiffwd, []), }