python类hpy()的实例源码

memprofiling.py 文件源码 项目:gbg 作者: rwbogl 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def heapyprofile():
    # pip install guppy
    # [works on python 2.7, AFAIK]
    from guppy import hpy
    import gc

    hp = hpy()
    ast = parse_file('/tmp/197.c')
    gc.collect()
    h = hp.heap()
    print(h)
DDebug.py 文件源码 项目:fandango 作者: tango-controls 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self,cl, name):
        U = PyTango.Util.instance()
        import gc,resource
        try:
            import guppy
            heapy = guppy.hpy()
        except:guppy,heapy = None,None
        DynamicDS.__init__(self,cl,name,_locals={'Util':U,'PyUtil':U,'self':self,'fandango':fandango,
            'resource':resource,'gc':gc,'guppy':guppy,'heapy':heapy},
            useDynStates=False)
        DDebug.init_device(self)
http.py 文件源码 项目:Windows-Agent 作者: AutohomeRadar 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def memory_usage():
    logging.info("fuck")
    h = hpy()
    result = str(h.heap()).replace("\n", "<br>")
    return result
spinel-cli.py 文件源码 项目:pyspinel 作者: openthread 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def do_debugmem(self, _line):
        """ Profile python memory usage. """
        from guppy import hpy
        heap_stats = hpy()
        print(heap_stats.heap())
        print()
        print(heap_stats.heap().byrcs)
StatsPlugin.py 文件源码 项目:zeronet-debian 作者: bashrc 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def getObjSize(self, obj, hpy=None):
        if hpy:
            return float(hpy.iso(obj).domisize) / 1024
        else:
            return 0

    # /Stats entry point
manager.py 文件源码 项目:pyomo 作者: Pyomo 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def initialize(self, *args, **kwds):
        """Initialize the scenario tree manager.

        A scenario tree manager must be initialized before using it.
        """

        init_start_time = time.time()
        result = None
        try:
            if self._options.verbose:
                print("Initializing %s with options:"
                      % (type(self).__name__))
                self.display_options()
                print("")
            ############# derived method
            result = self._init(*args, **kwds)
            #############
            if self._options.verbose:
                print("%s is successfully initialized"
                      % (type(self).__name__))

        except:
            if not self._inside_with_block:
                print("Exception encountered. Scenario tree manager "
                      "attempting to shut down.")
                print("Original Exception:")
                traceback.print_exception(*sys.exc_info())
                self.close()
            raise

        if self._options.output_times or \
           self._options.verbose:
            print("Overall initialization time=%.2f seconds"
                  % (time.time() - init_start_time))

        # gather and report memory statistics (for leak
        # detection purposes) if specified.
        if self._options.profile_memory:
            if guppy_available:
                print(hpy().heap())
            else:
                print("Guppy module is unavailable for "
                      "memory profiling")

        self._initialized = True

        return result


问题


面经


文章

微信
公众号

扫码关注公众号