Created
July 16, 2020 10:54
-
-
Save leifj/828ba0887d0660466bf7683ac8d97a9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def heapy(trace=False): | |
| def decorating(func): | |
| def new_func(*args, **kwargs): | |
| from gc import collect | |
| collect() | |
| from guppy import hpy | |
| hp = hpy() | |
| before = hp.heap() | |
| r = func(*args, **kwargs) | |
| after = hp.heap() | |
| leftover = after - before | |
| print("-----------------------------") | |
| print(args) | |
| print(kwargs) | |
| print(leftover) | |
| print("+++++++++++++++++++++++++++++") | |
| if trace: | |
| import pdb | |
| pdb.set_trace() | |
| return r | |
| return new_func | |
| return decorating |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment