Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ] 

001 import sys
002 from types import *
003 def mergeDict(src, dest):
004       for k in src.keys():
005             dest.setdefault(k,0)
006             dest[k] += src[k]
007       
008 
009 def sizeOf(obj, logger):
010 
011       objType  = type(obj)
012       
013       typeDict = {
014       BooleanType:         0,
015       BufferType:          0,
016       BuiltinFunctionType: 0,
017       BuiltinMethodType:   0,
018       ClassType:           0,
019       CodeType:            0,
020       ComplexType:         0,
021       DictProxyType:       0,
022       DictType:            0,
023       DictionaryType:      0,
024       EllipsisType:        0,
025       FileType:            0,
026       FloatType:           0,
027       FrameType:           0,
028       FunctionType:        0,
029       GeneratorType:       0,
030       InstanceType:        0,
031       IntType:             0,
032       LambdaType:          0,
033       ListType:            0,
034       LongType:            0,
035       MethodType:          0,
036       ModuleType:          0,
037       NoneType:            0,
038       NotImplementedType:  0,
039       ObjectType:          0,
040       SliceType:           0,
041       StringType:          0,
042       StringTypes:         0,
043       TracebackType:       0,
044       TupleType:           0,
045       TypeType:            0,
046       UnboundMethodType:   0,
047       UnicodeType:         0,
048       XRangeType:          0,
049       }
050       hasStorage = [type(()), type([]), type({}), type('s')]
051       for c in hasStorage:
052             key = str(c)+'_storage'
053             typeDict[key]=0
054 
055       if objType not in typeDict.keys():
056             logger.warning('sizeOf: unknown type, will not be counted: %s' % str(objType))
057             return {}
058       typeDict[objType] += 1
059       # for item in typeDict.items():
060       #      print '%30s   %5d' %  item
061 
062       #sys.exit(0)
063 
064       containers = [type(()), type([])]
065       if objType in containers:
066             typeDict[str(objType)+'_storage'] += len(obj)
067             
068             for e in obj:
069                   mergeDict(sizeOf(e, logger), typeDict)
070 
071 
072       if hasattr(obj, '__dict__'):
073             mergeDict(sizeOf(obj.__dict__, logger), typeDict)
074 
075       if objType == type('a'):
076             typeDict[str(objType)+'_storage'] += len(obj)
077                                          
078       if objType == type({}):
079             typeDict[str(objType)+'_storage'] += 2*len(obj)
080             [mergeDict(sizeOf(v, logger), typeDict) for v in obj.values()]
081             
082                   
083             
084             
085                   
086       
087       return typeDict
088 
089 if __name__ == '__main__':
090       class B:
091             def __init__(self):
092                   self.b = 1
093                   #self.bs = 'bbbbbbbbb'
094       class A:
095             def __init__(self):
096                   self.i = 0
097                   self.j = 4.2
098                   self.k = 'aaaa'
099                   self.dict = {}
100                   # self.bclass = B
101                   self.binst  = B()
102                   self.tup    = ()
103                   self.list   = []
104                   self.ty     = type('a')
105       from PseudoLogger import PseudoLogger
106       d = sizeOf(A(), PseudoLogger() )
107       print '-------final-----'
108       for k in d.keys():
109             if d[k]>0:
110                   print '%40s   %5d' % ( k, d[k])
111       print '-------final-----'
112  
113         

source navigation ] diff markup ] identifier search ] general search ]

Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems
This page was automatically generated by the LXR engine. Valid HTML 4.01!