當前位置: 首頁>>代碼示例>>Python>>正文


Python objgraph.show_most_common_types方法代碼示例

本文整理匯總了Python中objgraph.show_most_common_types方法的典型用法代碼示例。如果您正苦於以下問題:Python objgraph.show_most_common_types方法的具體用法?Python objgraph.show_most_common_types怎麽用?Python objgraph.show_most_common_types使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在objgraph的用法示例。


在下文中一共展示了objgraph.show_most_common_types方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: memusage

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_most_common_types [as 別名]
def memusage(do_dump_rpy_heap=True, do_objgraph=True):
    # type: (Optional[bool], Optional[bool]) -> str
    """Returning a str of memory usage stats"""
    def trap_err(func, *args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:  # pragma: nocover
            # include both __str/repr__, sometimes one's useless
            buf.writelines([func.__name__, ': ', repr(e), ': ', str(e)])

    buf = StringIO()
    rusage = trap_err(resource.getrusage, resource.RUSAGE_SELF)
    buf.writelines([repr(rusage), '\n\n'])
    trap_err(pmap_extended, buf)
    trap_err(jemalloc_stats, buf)
    trap_err(glibc_malloc_info, buf)
    if hasattr(gc, 'get_stats'):
        buf.writelines(['\n\n', gc.get_stats(), '\n\n'])
    if do_dump_rpy_heap:
        # dump rpython's heap before objgraph potentially pollutes the
        # heap with its heavy workload
        trap_err(dump_rpy_heap, buf)
    trap_err(get_stats_asmmemmgr, buf)
    buf.write('\n\n')
    if do_objgraph:
        trap_err(objgraph.show_most_common_types, limit=0, file=buf)
    return buf.getvalue() 
開發者ID:mozilla-services,項目名稱:autopush,代碼行數:29,代碼來源:memusage.py

示例2: show_types

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_most_common_types [as 別名]
def show_types():
    """- Print object type data to the console"""
    if objgraph is None:
        return "objgraph not installed"
    objgraph.show_most_common_types(limit=20)
    return "Printed to console" 
開發者ID:TotallyNotRobots,項目名稱:CloudBot,代碼行數:8,代碼來源:profiling.py

示例3: meminfo

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_most_common_types [as 別名]
def meminfo(ctx, **_):
    mem_info = StringIO()
    objgraph.show_most_common_types(file=mem_info)
    await util.say(ctx.channel, "```%s```" % mem_info.getvalue())
    mem_info = StringIO()
    objgraph.show_growth(file=mem_info)
    await util.say(ctx.channel, "```%s```" % mem_info.getvalue()) 
開發者ID:MacDue,項目名稱:DueUtil,代碼行數:9,代碼來源:misc.py

示例4: cmd_objgraph

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_most_common_types [as 別名]
def cmd_objgraph(self, channel, func='most_common_types()'):
        import objgraph

        await self.send_typing(channel)

        if func == 'growth':
            f = StringIO()
            objgraph.show_growth(limit=10, file=f)
            f.seek(0)
            data = f.read()
            f.close()

        elif func == 'leaks':
            f = StringIO()
            objgraph.show_most_common_types(objects=objgraph.get_leaking_objects(), file=f)
            f.seek(0)
            data = f.read()
            f.close()

        elif func == 'leakstats':
            data = objgraph.typestats(objects=objgraph.get_leaking_objects())

        else:
            data = eval('objgraph.' + func)

        return Response(data, codeblock='py') 
開發者ID:helionmusic,項目名稱:rhinobot_heroku,代碼行數:28,代碼來源:bot.py

示例5: show_types

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_most_common_types [as 別名]
def show_types():
    if objgraph is None:
        return "objgraph not installed"
    objgraph.show_most_common_types(limit=20)
    return "Printed to console" 
開發者ID:CloudBotIRC,項目名稱:CloudBot,代碼行數:7,代碼來源:profiling.py

示例6: display_used_mem

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_most_common_types [as 別名]
def display_used_mem():
    print("DISPLAY_USED_MEM_START");
    import gc
    gc.collect()
    import objgraph
    objgraph.show_most_common_types(limit=20)
    print("DISPLAY_USED_MEM_END");
    

# import '.' as pyaf_new_name
# pyaf=pyaf_new_name
# from pyaf 
開發者ID:antoinecarme,項目名稱:pyaf,代碼行數:14,代碼來源:test_mem_1.py

示例7: print_summary

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_most_common_types [as 別名]
def print_summary(f):
    '''
    Log a summary of current memory usage. This is very expensive
    when there is a lot of memory used.
    '''
    if os.path.isfile(f):
        print_objects(f)

    if not config.read('Crawl', 'DebugMemory'):
        return

    mem = {}
    for d in debugs:
        mem.update(d())

    LOGGER.info('Memory summary:')

    for k in sorted(mem.keys()):
        v = mem[k]
        LOGGER.info('  %s len %d bytes %s', k, v['len'], _in_millions(v['bytes']))

    LOGGER.info('Top objects:')

    gc.collect()
    lines = io.StringIO()
    objgraph.show_most_common_types(limit=20, file=lines)
    lines.seek(0)
    for l in lines.read().splitlines():
        LOGGER.info('  %s', l) 
開發者ID:cocrawler,項目名稱:cocrawler,代碼行數:31,代碼來源:memory.py

示例8: run_objgraph

# 需要導入模塊: import objgraph [as 別名]
# 或者: from objgraph import show_most_common_types [as 別名]
def run_objgraph(types):
    import objgraph
    import os
    import random
    objgraph.show_most_common_types(limit=50, shortnames=False)
    for type_ in types:
        count = objgraph.count(type_)
        print('%s objects: %d' % (type_, count))
        if count:
            objgraph.show_backrefs(
                random.choice(objgraph.by_type(type_)), max_depth=20,
                filename='/tmp/backrefs_%s_%d.dot' % (type_, os.getpid())) 
開發者ID:open-io,項目名稱:oio-swift,代碼行數:14,代碼來源:runserver.py


注:本文中的objgraph.show_most_common_types方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。