Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 2422:6aa75e77cafe
add --lsprof option. 3x faster than --profile, more useful output.
results include calls to c code and nested calls.
requires python 2.5 or lsprof installed from svn at
http://codespeak.net/svn/user/arigo/hack/misc/lsprof/
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 09 Jun 2006 12:05:17 -0700 |
parents | 3a4ae3970af3 |
children | 42b8a1ff46cf |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Jun 09 09:14:52 2006 -0700 +++ b/mercurial/commands.py Fri Jun 09 12:05:17 2006 -0700 @@ -3158,6 +3158,7 @@ ('', 'config', [], _('set/override config option')), ('', 'debug', None, _('enable debugging output')), ('', 'debugger', None, _('start debugger')), + ('', 'lsprof', None, _('print improved command execution profile')), ('', 'traceback', None, _('print traceback on exception')), ('', 'time', None, _('time how long the command takes')), ('', 'profile', None, _('print command execution profile')), @@ -3385,6 +3386,22 @@ stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_stats(40) + elif options['lsprof']: + try: + from mercurial import lsprof + except ImportError: + raise util.Abort(_( + 'lsprof not available - install from ' + 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/')) + p = lsprof.Profiler() + p.enable(subcalls=True) + try: + return d() + finally: + p.disable() + stats = lsprof.Stats(p.getstats()) + stats.sort() + stats.pprint(top=10, file=sys.stderr, climit=5) else: return d() finally: