Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
I may be slow to respond.

Dmitry Sichkar dmmeteo

🦄
I may be slow to respond.
View GitHub Profile
@dmmeteo
dmmeteo / mem.py
Created Jul 15, 2020 — forked from vald-phoenix/mem.py
A dummy decorator function to measure memory usage of a Python function, method, etc.
View mem.py
import resource
from functools import wraps
def mem_it(func):
@wraps(func)
def wrapper(*args, **kwargs):
print(
'Pre-memory usage: {} (mb)'.format(
resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024