~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lsprof.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-11 21:41:24 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080711214124-qi09irlj7pd5cuzg
Shortcut the case when one revision is in the ancestry of the other.

At the cost of a heads() check, when one parent supersedes, we don't have to extract
the text for the other. Changes merge time from 3m37s => 3m21s. Using a
CachingParentsProvider would drop the time down to 3m11s.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
from _lsprof import Profiler, profiler_entry
12
12
 
13
13
 
 
14
import bzrlib.osutils
 
15
 
 
16
 
14
17
__all__ = ['profile', 'Stats']
15
18
 
16
19
_g_threadmap = {}
27
30
 
28
31
 
29
32
def profile(f, *args, **kwds):
30
 
    """Run a function profile.
31
 
    
32
 
    :return: The functions return value and a stats object.
33
 
    """
 
33
    """XXX docstring"""
34
34
    global _g_threadmap
35
35
    p = Profiler()
36
36
    p.enable(subcalls=True)
131
131
            otherwise the format is given by the filename extension.
132
132
        """
133
133
        if format is None:
134
 
            basename = os.path.basename(filename)
 
134
            basename = bzrlib.osutils.basename(filename)
135
135
            if basename.startswith('callgrind.out'):
136
136
                format = "callgrind"
137
137
            else:
138
 
                ext = os.path.splitext(filename)[1]
 
138
                ext = bzrlib.osutils.splitext(filename)[1]
139
139
                if len(ext) > 1:
140
140
                    format = ext[1:]
141
141
        outfile = open(filename, 'wb')