comparison 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
comparison
equal deleted inserted replaced
2418:99835097bca9 2422:6aa75e77cafe
3156 ('q', 'quiet', None, _('suppress output')), 3156 ('q', 'quiet', None, _('suppress output')),
3157 ('v', 'verbose', None, _('enable additional output')), 3157 ('v', 'verbose', None, _('enable additional output')),
3158 ('', 'config', [], _('set/override config option')), 3158 ('', 'config', [], _('set/override config option')),
3159 ('', 'debug', None, _('enable debugging output')), 3159 ('', 'debug', None, _('enable debugging output')),
3160 ('', 'debugger', None, _('start debugger')), 3160 ('', 'debugger', None, _('start debugger')),
3161 ('', 'lsprof', None, _('print improved command execution profile')),
3161 ('', 'traceback', None, _('print traceback on exception')), 3162 ('', 'traceback', None, _('print traceback on exception')),
3162 ('', 'time', None, _('time how long the command takes')), 3163 ('', 'time', None, _('time how long the command takes')),
3163 ('', 'profile', None, _('print command execution profile')), 3164 ('', 'profile', None, _('print command execution profile')),
3164 ('', 'version', None, _('output version information and exit')), 3165 ('', 'version', None, _('output version information and exit')),
3165 ('h', 'help', None, _('display help and exit')), 3166 ('h', 'help', None, _('display help and exit')),
3383 prof.close() 3384 prof.close()
3384 stats = hotshot.stats.load("hg.prof") 3385 stats = hotshot.stats.load("hg.prof")
3385 stats.strip_dirs() 3386 stats.strip_dirs()
3386 stats.sort_stats('time', 'calls') 3387 stats.sort_stats('time', 'calls')
3387 stats.print_stats(40) 3388 stats.print_stats(40)
3389 elif options['lsprof']:
3390 try:
3391 from mercurial import lsprof
3392 except ImportError:
3393 raise util.Abort(_(
3394 'lsprof not available - install from '
3395 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
3396 p = lsprof.Profiler()
3397 p.enable(subcalls=True)
3398 try:
3399 return d()
3400 finally:
3401 p.disable()
3402 stats = lsprof.Stats(p.getstats())
3403 stats.sort()
3404 stats.pprint(top=10, file=sys.stderr, climit=5)
3388 else: 3405 else:
3389 return d() 3406 return d()
3390 finally: 3407 finally:
3391 u.flush() 3408 u.flush()
3392 except: 3409 except: