示例#1
0
def print_memory_diff():
    return
    usage = get_size(get_objects())
    if print_memory_diff._usage:
        print u"Memory usage diff: %d Kb" % ((usage-print_memory_diff._usage)/1024)
    else:
        print u"Memory usage: %d Kb" % (usage/1024)
    print_memory_diff._usage = usage
 def profile(self, frame, event, arg): #PYCHOK arg requ. to match signature
     """Profiling method used to profile matching codepoints and events."""
     if (self.events == None) or (event in self.events):
         frame_info = inspect.getframeinfo(frame)
         cp = (frame_info[0], frame_info[2], frame_info[1])
         if self.codepoint_included(cp):
             objects = muppy.get_objects()
             size = muppy.get_size(objects)
             if cp not in self.memories:
                 self.memories[cp] = [0,0,0,0]
                 self.memories[cp][0] = 1
                 self.memories[cp][1] = size
                 self.memories[cp][2] = size
             else:
                 self.memories[cp][0] += 1
                 if self.memories[cp][1] > size:
                     self.memories[cp][1] = size
                 if self.memories[cp][2] < size:
                     self.memories[cp][2] = size
示例#3
0
    
    
if __name__=='__main__':
    initialize()
    tr = tracker.SummaryTracker()
    run(title)
    close()
    
    #profile.run("run_same(store, 5)", filename='vslib.profile')
    tr.print_diff()
    
    #p = pstats.Stats('vslib.profile')
    #p.sort_stats('cumulative').print_stats(20)
if 0:
    objects = muppy.get_objects(include_frames=True)
    print muppy.get_size(objects)
    sum1 = summary.summarize(objects)
    summary.print_(sum1)
if 0:
    root = ''
    ib = refbrowser.InteractiveBrowser(root)
    ib.main()
if 1:
    import objgraph, inspect
    objgraph.show_most_common_types(limit=30)
    if objgraph.count('document') > 0:
        print 'document:', objgraph.count('document')
        docs = objgraph.by_type('document')
        d = docs[0]
        objgraph.show_backrefs(docs, max_depth=10)
        #chain = objgraph.find_backref_chain(d, inspect.ismodule)