Mercurial > hg-stable
changeset 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 | 075619d00dd7 |
children | 273f6a01d18b |
files | mercurial/commands.py |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Jun 10 12:49:25 2005 -0800 +++ b/mercurial/commands.py Fri Jun 10 13:48:08 2005 -0800 @@ -595,6 +595,7 @@ opts = [('v', 'verbose', None, 'verbose'), ('d', 'debug', None, 'debug'), ('q', 'quiet', None, 'quiet'), + ('p', 'profile', None, 'profile'), ('y', 'noninteractive', None, 'run non-interactively'), ] @@ -633,7 +634,18 @@ d = lambda: i[0](u, *args, **cmdoptions) try: - return d() + if options['profile']: + import hotshot, hotshot.stats + prof = hotshot.Profile("hg.prof") + r = prof.runcall(d) + prof.close() + stats = hotshot.stats.load("hg.prof") + stats.strip_dirs() + stats.sort_stats('time', 'calls') + stats.print_stats(40) + return r + else: + return d() except SignalInterrupt: u.warn("killed!\n") except KeyboardInterrupt: