Skip to content

Instantly share code, notes, and snippets.

@stengaard
Created March 13, 2013 15:05
Show Gist options
  • Save stengaard/5152995 to your computer and use it in GitHub Desktop.
Save stengaard/5152995 to your computer and use it in GitHub Desktop.
def profile_this(fn):
import cProfile
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment