Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 309:61414da06fe5
add easy profiling support
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
add easy profiling support
Now you can do hg -p [command] and it will run it under the hotshot
profiler
manifest hash: fcad346798243ad2434bc5458ed8d3456707c599
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCqgqYywK+sNU5EO8RAp9BAJsFI7iUWYEMvXWYaVt4VmrlOF3enwCdEFRJ
l/EZmMLecbfQcbbh5oo0yHs=
=voa0
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Fri, 10 Jun 2005 13:48:08 -0800 |
parents | f06a4a3b86a7 |
children | 273f6a01d18b |
comparison
equal
deleted
inserted
replaced
308:075619d00dd7 | 309:61414da06fe5 |
---|---|
593 def dispatch(args): | 593 def dispatch(args): |
594 options = {} | 594 options = {} |
595 opts = [('v', 'verbose', None, 'verbose'), | 595 opts = [('v', 'verbose', None, 'verbose'), |
596 ('d', 'debug', None, 'debug'), | 596 ('d', 'debug', None, 'debug'), |
597 ('q', 'quiet', None, 'quiet'), | 597 ('q', 'quiet', None, 'quiet'), |
598 ('p', 'profile', None, 'profile'), | |
598 ('y', 'noninteractive', None, 'run non-interactively'), | 599 ('y', 'noninteractive', None, 'run non-interactively'), |
599 ] | 600 ] |
600 | 601 |
601 args = fancyopts.fancyopts(args, opts, options, | 602 args = fancyopts.fancyopts(args, opts, options, |
602 'hg [options] <command> [options] [files]') | 603 'hg [options] <command> [options] [files]') |
631 d = lambda: i[0](u, repo, *args, **cmdoptions) | 632 d = lambda: i[0](u, repo, *args, **cmdoptions) |
632 else: | 633 else: |
633 d = lambda: i[0](u, *args, **cmdoptions) | 634 d = lambda: i[0](u, *args, **cmdoptions) |
634 | 635 |
635 try: | 636 try: |
636 return d() | 637 if options['profile']: |
638 import hotshot, hotshot.stats | |
639 prof = hotshot.Profile("hg.prof") | |
640 r = prof.runcall(d) | |
641 prof.close() | |
642 stats = hotshot.stats.load("hg.prof") | |
643 stats.strip_dirs() | |
644 stats.sort_stats('time', 'calls') | |
645 stats.print_stats(40) | |
646 return r | |
647 else: | |
648 return d() | |
637 except SignalInterrupt: | 649 except SignalInterrupt: |
638 u.warn("killed!\n") | 650 u.warn("killed!\n") |
639 except KeyboardInterrupt: | 651 except KeyboardInterrupt: |
640 u.warn("interrupted!\n") | 652 u.warn("interrupted!\n") |
641 except IOError, inst: | 653 except IOError, inst: |