当前位置: 首页>>代码示例>>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;未经允许,请勿转载。