本文整理汇总了Python中pstats.Stats.calc_callees方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.calc_callees方法的具体用法?Python Stats.calc_callees怎么用?Python Stats.calc_callees使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pstats.Stats
的用法示例。
在下文中一共展示了Stats.calc_callees方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pstats import Stats [as 别名]
# 或者: from pstats.Stats import calc_callees [as 别名]
class Stat:
"""manage interface between pstat data and GUI item"""
def __init__(self, pstat=None, path=None):
# pStat profile statistics instance
self.pstat = None
self.load(pstat, path)
self.itemArray = {}
self.itemArray[TAB_FUNCTIONSTAT] = {}
self.itemArray[TAB_SOURCE] = {}
# Reference from pstat key to Qt object in the GUI
self.pStatArray = {}
self.pStatArray[TAB_FUNCTIONSTAT] = {}
self.pStatArray[TAB_SOURCE] = {}
def getTotalTime(self):
if self.pstat:
return self.pstat.total_tt
else:
return 0
def getCallNumber(self):
if self.pstat:
return self.pstat.total_calls
else:
return 0
def getPrimitiveCallRatio(self):
if self.pstat:
return 100.0 * float(self.pstat.prim_calls) / float(
self.pstat.total_calls)
else:
return 0
def getStatNumber(self):
if self.pstat:
return len(self.pstat.stats)
else:
return 0
def getStatItems(self):
if self.pstat:
return list(self.pstat.stats.items())
def getStatKeys(self):
if self.pstat:
return list(self.pstat.stats.keys())
def getCalleesItems(self):
if self.pstat:
return list(self.pstat.all_callees.items())
def getStatTotalTime(self, pstatTriplet):
if self.pstat:
try:
return self.pstat.stats[pstatTriplet][2]
except KeyError:
return 0
else:
return 0
def getStatCumulativeTime(self, pstatTriplet):
if self.pstat:
try:
return self.pstat.stats[pstatTriplet][3]
except KeyError:
return 0
else:
return 0
def load(self, pstat=None, path=None):
if pstat and path:
print('''' Warning : both pstat and path parameter given.
path override pstat !''')
if pstat:
self.pstat = pstat
if path:
self.pstat = Stats(str(path))
if self.pstat:
self.pstat.calc_callees()
def save(self, path):
try:
self.pstat.dump_stats(path)
except:
pass
def setStatLink(self, guiItem, pstatTriplet, target):
self.itemArray[target][guiItem] = pstatTriplet
self.pStatArray[target][pstatTriplet] = guiItem
def getPstatFromGui(self, guiItem, target):
try:
return self.itemArray[target][guiItem]
except KeyError:
return None
def getGuiFromPstat(self, pStatTtriplet, target):
try:
return self.pStatArray[target][pStatTtriplet]
except KeyError:
#.........这里部分代码省略.........