Ver Fonte

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

Darren Ranalli há 18 anos atrás
pai
commit
6907ad6543
1 ficheiros alterados com 8 adições e 5 exclusões
  1. 8 5
      direct/src/showbase/ObjectPool.py

+ 8 - 5
direct/src/showbase/ObjectPool.py

@@ -13,15 +13,16 @@ 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()
-        self.gained.printObjsByType()
-        print '\n\nGAINED-OBJECT REFERRERS\n'
-        self.gained.printReferrers(1)
+        if full:
+            self.gained.printObjsByType()
+            print '\n\nGAINED-OBJECT REFERRERS\n'
+            self.gained.printReferrers(1)
 
 class ObjectPool:
     """manipulate a pool of Python objects"""
@@ -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: