added inline profiling pseudo-support

This commit is contained in:
Darren Ranalli 2003-04-01 01:33:44 +00:00
parent 468393c070
commit 5472152a5a
1 changed files with 15 additions and 2 deletions

View File

@ -462,12 +462,25 @@ PyUtilProfileDefaultSorts = ['cumulative', 'time', 'calls']
# call this from the prompt, and break back out to the prompt
# to stop profiling
#
# OR to do inline profiling, you must make a globally-visible
# function to be profiled, i.e. to profile 'self.load()', do
# something like this:
#
# def func(self=self):
# self.load()
# import __builtin__
# __builtin__.func = func
# PythonUtil.startProfile(cmd='func()', filename='loadProfile')
# del __builtin__.func
#
def startProfile(filename=PyUtilProfileDefaultFilename,
lines=PyUtilProfileDefaultLines,
sorts=PyUtilProfileDefaultSorts,
silent=0):
silent=0,
cmd='run()'):
import profile
profile.run('run()', filename)
profile.run(cmd, filename)
if not silent:
printProfile(filename, lines, sorts)