From 5472152a5a175aaf16863d2f32a2e3a5dec2269e Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Tue, 1 Apr 2003 01:33:44 +0000 Subject: [PATCH] added inline profiling pseudo-support --- direct/src/showbase/PythonUtil.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 1899bc7d6c..faeed502ac 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -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)