Python guppy 模块,hpy() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用guppy.hpy()

项目:gbg    作者:rwbogl    | 项目源码 | 文件源码
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)
项目:fandango    作者:tango-controls    | 项目源码 | 文件源码
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)
项目:Windows-Agent    作者:AutohomeRadar    | 项目源码 | 文件源码
def memory_usage():
    logging.info("fuck")
    h = hpy()
    result = str(h.heap()).replace("\n", "<br>")
    return result
项目:pyspinel    作者:openthread    | 项目源码 | 文件源码
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)
项目:zeronet-debian    作者:bashrc    | 项目源码 | 文件源码
def getObjSize(self, obj, hpy=None):
        if hpy:
            return float(hpy.iso(obj).domisize) / 1024
        else:
            return 0

    # /Stats entry point
项目:pyomo    作者:Pyomo    | 项目源码 | 文件源码
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