Last active
September 18, 2019 10:18
-
-
Save Jan-Zeiseweis/0f793c68cdc60daccce9dae6889633ce to your computer and use it in GitHub Desktop.
This file contains 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
import cProfile | |
from datetime import datetime | |
def profileit(func): | |
def wrapper(*args, **kwargs): | |
datafn = f"{func.__name__}_{datetime.now().strftime('%Y%m%d_%H%M%S_%f')}.profile" | |
prof = cProfile.Profile() | |
retval = prof.runcall(func, *args, **kwargs) | |
prof.dump_stats(datafn) | |
return retval | |
return wrapper | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment