Python guppy.hpy() Examples
The following are 13
code examples of guppy.hpy().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
guppy
, or try the search function
.
Example #1
Source File: Remote.py From guppy3 with MIT License | 6 votes |
def help_int(self): print("""int ----- Interactive console. Bring up a Python console in the Remote Control interpreter. This console will initially have access to a heapy constructor, named hpy, and a ready-made instance, named hp, and the target (see also the reset command). Other things may be imported as needed. After returning to the Annex (by q) or to the Monitor (by . or <Ctrl-C>), the data in the interactive console will remain there - and will be available till the next time the console is entered. But the data may be cleared and reset to the initial state - a new heapy instance will be created - by the 'reset' command of Annex. It should be noted that the interpreter thread under investigation is executing in parallell with the remote control interpreter. So there may be some problems to do with that if both are executing at the same time. This has to be dealt with for each case specifically.""", file=self.stdout)
Example #2
Source File: Remote.py From guppy3 with MIT License | 6 votes |
def help_reset(self): print("""reset ----- Reset things to an initial state. This resets the state of the interactive console data only, for now. It is reinitialized to contain the following: hpy --- from guppy import hpy hp --- hp = hpy() target --- a reference to some data in the target interpreter h --- h = hp; h is a shorthand for hp (The hpy function is modified here from the normal one so it sets some options to make it be concerned with the target interpreter heap under investigation rather than the current one.) """, file=self.stdout)
Example #3
Source File: telnet.py From learn_python3_spider with MIT License | 6 votes |
def _get_telnet_vars(self): # Note: if you add entries here also update topics/telnetconsole.rst telnet_vars = { 'engine': self.crawler.engine, 'spider': self.crawler.engine.spider, 'slot': self.crawler.engine.slot, 'crawler': self.crawler, 'extensions': self.crawler.extensions, 'stats': self.crawler.stats, 'settings': self.crawler.settings, 'est': lambda: print_engine_status(self.crawler.engine), 'p': pprint.pprint, 'prefs': print_live_refs, 'hpy': hpy, 'help': "This is Scrapy telnet console. For more info see: " "https://docs.scrapy.org/en/latest/topics/telnetconsole.html", } self.crawler.signals.send_catch_log(update_telnet_vars, telnet_vars=telnet_vars) return telnet_vars
Example #4
Source File: telnet.py From learn_python3_spider with MIT License | 6 votes |
def _get_telnet_vars(self): # Note: if you add entries here also update topics/telnetconsole.rst telnet_vars = { 'engine': self.crawler.engine, 'spider': self.crawler.engine.spider, 'slot': self.crawler.engine.slot, 'crawler': self.crawler, 'extensions': self.crawler.extensions, 'stats': self.crawler.stats, 'settings': self.crawler.settings, 'est': lambda: print_engine_status(self.crawler.engine), 'p': pprint.pprint, 'prefs': print_live_refs, 'hpy': hpy, 'help': "This is Scrapy telnet console. For more info see: " "https://docs.scrapy.org/en/latest/topics/telnetconsole.html", } self.crawler.signals.send_catch_log(update_telnet_vars, telnet_vars=telnet_vars) return telnet_vars
Example #5
Source File: http.py From Windows-Agent with Apache License 2.0 | 5 votes |
def memory_usage(): logging.info("fuck") h = hpy() result = str(h.heap()).replace("\n", "<br>") return result
Example #6
Source File: server_benchmark.py From ga4gh-server with Apache License 2.0 | 5 votes |
def __init__(self, registryDb): repo = datarepo.SqlDataRepository(registryDb) repo.open(datarepo.MODE_READ) super(HeapProfilerBackend, self).__init__(repo) self.profiler = guppy.hpy()
Example #7
Source File: Remote.py From guppy3 with MIT License | 5 votes |
def do_reset(self, arg): self.intlocals.clear() self.intlocals.update( {'hpy': self.hpy, 'hp': self.hpy(), 'target': self.target }) # Set shorthand h, it is so commonly used # and the instance name now used in README example etc self.intlocals['h'] = self.intlocals['hp']
Example #8
Source File: Remote.py From guppy3 with MIT License | 5 votes |
def hpy(self, *args, **kwds): from guppy import hpy hp = hpy(*args, **kwds) hp.View.is_hiding_calling_interpreter = 1 hp.View.target = self.target self.target._hiding_tag_ = hp._hiding_tag_ self.target.close._hiding_tag_ = hp._hiding_tag_ hp.reprefix = 'hp.' return hp
Example #9
Source File: test_ER.py From guppy3 with MIT License | 5 votes |
def test_4(self): ' Test of via ' # Esp. representation, construction class C: pass c = C() hp = self.heapy.Use isod = hp.iso(c.__dict__) x = isod.by('Via').kind self.aseq(repr(x), "hpy().Via('.__dict__')")
Example #10
Source File: check_MemoryUse.py From Kayak with MIT License | 5 votes |
def check_NodeMemory(): # Not a test. Useful for checking how much memory a node uses. np_A = npr.randn(5,6) A = kayak.Parameter(np_A) N = int(1e4) h = hpy() h.setref() for i in xrange(N): A = kayak.Identity(A) print "Created 10,000 objects" print h.heap()
Example #11
Source File: spinel-cli.py From pyspinel with Apache License 2.0 | 5 votes |
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)
Example #12
Source File: runbook_profiler.py From runbook with Apache License 2.0 | 5 votes |
def __call__(self, func): @wraps(func) def wrapper(*args, **kwargs): gc.disable() start = hpy().heap().size res = func(*args, **kwargs) end = hpy().heap().size gc.enable() mem_log(name=func.__name__, totmembytes=end , memdiffbytes=(end-start), args=self.arg_extractor(*args, **kwargs)) return res return wrapper
Example #13
Source File: runbook_profiler.py From runbook with Apache License 2.0 | 5 votes |
def __call__(self, func): @wraps(func) def wrapper(*args, **kwargs): gc.disable() start = hpy().heap().size res = func(*args, **kwargs) end = hpy().heap().size gc.enable() mem_log(name=func.__name__, totmembytes=end , memdiffbytes=(end-start), args=self.arg_extractor(*args, **kwargs)) return res return wrapper