[MERGE] Minor profiling fixes
Robert Collins
robertc at robertcollins.net
Mon Sep 10 04:12:46 BST 2007
On Mon, 2007-09-10 at 13:06 +1000, Ian Clatworthy wrote:
bb:resubmit
> === modified file 'bzrlib/lsprof.py'
> --- bzrlib/lsprof.py 2007-07-30 01:55:44 +0000
> +++ bzrlib/lsprof.py 2007-09-10 02:49:07 +0000
> @@ -31,8 +31,16 @@
> p = Profiler()
> p.enable(subcalls=True)
> threading.setprofile(_thread_profile)
> + # Note: The except clause is needed below so that profiling data
> still
> + # gets dumped even when exceptions are encountered. The except
> clause code
> + # is taken straight from run_bzr_catch_errrors() in commands.py
> and ought
> + # to be kept in sync with it.
> try:
> ret = f(*args, **kwds)
> + except (KeyboardInterrupt, Exception), e:
> + import bzrlib.trace
> + bzrlib.trace.report_exception(sys.exc_info(), sys.stderr)
> + ret = 3
> finally:
Why not just profile run_bzr_catch_errors instead of duplicating code?
That would be much simpler.
Also, KeyboardInterrupt is an Exception, so that code is clearly wrong
regardless.
> @@ -118,7 +126,8 @@
> otherwise the format is given by the filename extension.
> """
> if format is None:
> - if filename.startswith('callgrind.out'):
> + basename = os.path.basename(filename)
> + if basename.startswith('callgrind.out'):
> format = "callgrind"
> else:
> ext = os.path.splitext(filename)[1]
This is unfriendly to windows - did you see Alexanders mail about not
using os.path functions ?
-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070910/0db88b81/attachment.pgp
More information about the bazaar
mailing list