Created
August 16, 2016 08:49
-
-
Save hartred/34e94524ad03684454b7901a72b708df to your computer and use it in GitHub Desktop.
custom decorator for writing profiling information to a file
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 profile_memory(output): | |
if isinstance(output, str): | |
output = open(output, 'w') | |
def decorator(func): | |
@profile(stream=output) | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
result = func(*args, **kwargs) | |
return result | |
return wrapper | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment