mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
added caller/callee printout to printProfile
This commit is contained in:
parent
ad09b6fbbd
commit
9a2ff1bac0
@ -589,29 +589,34 @@ PyUtilProfileDefaultSorts = ['cumulative', 'time', 'calls']
|
|||||||
# self.load()
|
# self.load()
|
||||||
# import __builtin__
|
# import __builtin__
|
||||||
# __builtin__.func = func
|
# __builtin__.func = func
|
||||||
# PythonUtil.startProfile(cmd='func()', filename='loadProfile')
|
# PythonUtil.startProfile(cmd='func()', filename='profileData')
|
||||||
# del __builtin__.func
|
# del __builtin__.func
|
||||||
#
|
#
|
||||||
def startProfile(filename=PyUtilProfileDefaultFilename,
|
def startProfile(filename=PyUtilProfileDefaultFilename,
|
||||||
lines=PyUtilProfileDefaultLines,
|
lines=PyUtilProfileDefaultLines,
|
||||||
sorts=PyUtilProfileDefaultSorts,
|
sorts=PyUtilProfileDefaultSorts,
|
||||||
silent=0,
|
silent=0,
|
||||||
|
callInfo=1,
|
||||||
cmd='run()'):
|
cmd='run()'):
|
||||||
import profile
|
import profile
|
||||||
profile.run(cmd, filename)
|
profile.run(cmd, filename)
|
||||||
if not silent:
|
if not silent:
|
||||||
printProfile(filename, lines, sorts)
|
printProfile(filename, lines, sorts, callInfo)
|
||||||
|
|
||||||
# call this to see the results again
|
# call this to see the results again
|
||||||
def printProfile(filename=PyUtilProfileDefaultFilename,
|
def printProfile(filename=PyUtilProfileDefaultFilename,
|
||||||
lines=PyUtilProfileDefaultLines,
|
lines=PyUtilProfileDefaultLines,
|
||||||
sorts=PyUtilProfileDefaultSorts,):
|
sorts=PyUtilProfileDefaultSorts,
|
||||||
|
callInfo=1):
|
||||||
import pstats
|
import pstats
|
||||||
s = pstats.Stats(filename)
|
s = pstats.Stats(filename)
|
||||||
s.strip_dirs()
|
s.strip_dirs()
|
||||||
for sort in sorts:
|
for sort in sorts:
|
||||||
s.sort_stats(sort)
|
s.sort_stats(sort)
|
||||||
s.print_stats(lines)
|
s.print_stats(lines)
|
||||||
|
if callInfo:
|
||||||
|
s.print_callees(lines)
|
||||||
|
s.print_callers(lines)
|
||||||
|
|
||||||
class Functor:
|
class Functor:
|
||||||
def __init__(self, function, *args, **kargs):
|
def __init__(self, function, *args, **kargs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user