~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lsprof.py

  • Committer: John Arbash Meinel
  • Date: 2008-10-30 00:55:00 UTC
  • mto: (3815.2.5 prepare-1.9)
  • mto: This revision was merged to the branch mainline in revision 3811.
  • Revision ID: john@arbash-meinel.com-20081030005500-r5cej1cxflqhs3io
Switch so that we are using a simple timestamp as the first action.

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
 
 
17
14
__all__ = ['profile', 'Stats']
18
15
 
19
16
_g_threadmap = {}
30
27
 
31
28
 
32
29
def profile(f, *args, **kwds):
33
 
    """XXX docstring"""
 
30
    """Run a function profile.
 
31
    
 
32
    :return: The functions return value and a stats object.
 
33
    """
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 = bzrlib.osutils.basename(filename)
 
134
            basename = os.path.basename(filename)
135
135
            if basename.startswith('callgrind.out'):
136
136
                format = "callgrind"
137
137
            else:
138
 
                ext = bzrlib.osutils.splitext(filename)[1]
 
138
                ext = os.path.splitext(filename)[1]
139
139
                if len(ext) > 1:
140
140
                    format = ext[1:]
141
141
        outfile = open(filename, 'wb')