~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lsprof.py

  • Committer: Aaron Bentley
  • Date: 2007-12-09 23:53:50 UTC
  • mto: This revision was merged to the branch mainline in revision 3133.
  • Revision ID: aaron.bentley@utoronto.ca-20071209235350-qp39yk0xzx7a4f6p
Don't use the base if not cherrypicking

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')