added support for optional printing of object instances and referrers, print types with small number of instances first

This commit is contained in:
Darren Ranalli 2007-11-14 01:53:21 +00:00
parent 50a3d5d0ac
commit 6907ad6543

View File

@ -13,12 +13,13 @@ class Diff:
def __init__(self, lost, gained):
self.lost=lost
self.gained=gained
def printOut(self):
def printOut(self, full=False):
print 'lost %s objects, gained %s objects' % (len(self.lost), len(self.gained))
print '\n\nself.lost\n'
print self.lost.typeFreqStr()
print '\n\nself.gained\n'
print self.gained.typeFreqStr()
if full:
self.gained.printObjsByType()
print '\n\nGAINED-OBJECT REFERRERS\n'
self.gained.printReferrers(1)
@ -102,7 +103,9 @@ class ObjectPool:
print '\n============================'
counts = list(set(self._count2types.keys()))
counts.sort()
counts.reverse()
# print types with the smallest number of instances first, in case
# there's a large group that waits a long time before printing
#counts.reverse()
for count in counts:
types = makeList(self._count2types[count])
for typ in types: