Created
March 20, 2013 19:17
-
-
Save durden/5207587 to your computer and use it in GitHub Desktop.
Profile decorator take from rwarren talk, 'A brief intro to profiling in Python'
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
def profile_this(fn): | |
def profiled_fn(*args, **kwargs): | |
fpath = fn.__name__ + '.profile' | |
prof = cProfile.Profile() | |
ret = prof.runcall(fn, *args, **kwargs) | |
prof.dump_stats(fpath) | |
return ret | |
return profiled_fn | |
@profile_this | |
def silly_delay(): | |
[f() for f in (delay1, delay2, delay3)] | |
Taken from: [https://speakerdeck.com/rwarren/a-brief-intro-to-profiling-in-python](https://speakerdeck.com/rwarren/a-brief-intro-to-profiling-in-python) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment